PTdecode/CImg-1.3.0/html/reference/structcimg__library_1_1CImgException.html

Mon, 03 Aug 2009 23:41:04 +0100

author
Philip Pemberton <philpem@philpem.me.uk>
date
Mon, 03 Aug 2009 23:41:04 +0100
changeset 11
69416826d18c
parent 5
1204ebf9340d
permissions
-rwxr-xr-x

added dep/*.d and obj/*.o to hgignore

philpem@5 1 xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
philpem@5 2 <head>
philpem@5 3 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></meta>
philpem@5 4 <title>The CImg Library - C++ Template Image Processing Toolkit</title>
philpem@5 5 <meta content="David Tschumperle" name="author"></meta>
philpem@5 6 <link rel="shortcut icon" type="image/x-icon" href="http://cimg.sourceforge.net/favicon.ico"></link>
philpem@5 7 <link rel="icon" type="image/png" href="favicon.png"></link>
philpem@5 8 <link href="doxygen.css" rel="stylesheet" type="text/css">
philpem@5 9 <link href="tabs.css" rel="stylesheet" type="text/css">
philpem@5 10 <style type="text/css">
philpem@5 11 <!--
philpem@5 12 body {background-color:white; font-family:sans-serif; }
philpem@5 13 a:active{text-decoration:none; color:#303090}
philpem@5 14 a:link{text-decoration:none; color:#303090}
philpem@5 15 a:visited{text-decoration:none; color:#303090}
philpem@5 16 a:hover{text-decoration:underline; color:#4E9F71}
philpem@5 17 -->
philpem@5 18 </style>
philpem@5 19 <script language="JavaScript" type="text/javascript">
philpem@5 20 <!-- Original: Eric King (eric_andrew_king@hotmail.com) is used to display images in popup windows -->
philpem@5 21 <!-- Web Site: http://redrival.com/eak/ -->
philpem@5 22 <!-- This script and many more are available free online at -->
philpem@5 23 <!-- The JavaScript Source!! http://javascript.internet.com -->
philpem@5 24 <!-- Begin
philpem@5 25 function NewWindow(mypage, myname, w, h, scroll) {
philpem@5 26 var winl = (screen.width - w) / 2;
philpem@5 27 var wint = (screen.height - h) / 2;
philpem@5 28 winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
philpem@5 29 win = window.open(mypage, myname, winprops)
philpem@5 30 if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
philpem@5 31 }
philpem@5 32 // End -->
philpem@5 33 </script>
philpem@5 34 </head>
philpem@5 35 <body>
philpem@5 36 <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
philpem@5 37 <tbody><tr><td>
philpem@5 38 <hr noshade="noshade" size="1" width="90%"></hr>
philpem@5 39 <center>
philpem@5 40 <br/>
philpem@5 41 <a href="http://cimg.sourceforge.net"><img src="http://cimg.sourceforge.net/img/CImgLogo.jpg" alt="" border="0"></img></a><br/>
philpem@5 42 <br/>
philpem@5 43 </center>
philpem@5 44 <hr noshade="noshade" size="1" width="90%"></hr>
philpem@5 45 <center>
philpem@5 46 <table bgcolor="#EEEEFF" style="width: 90%; text-align: left; margin-left: auto; margin-right: auto;" border="0" cellpadding="3" cellspacing="0">
philpem@5 47 <tbody><tr><td style="text-align: center; vertical-align: top;">
philpem@5 48 <font color="#FFFFFF" face="Arial,Helvetica" size="-1">
philpem@5 49 <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/index.shtml">Main</a> <b>]</b>
philpem@5 50 <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/news.shtml">News</a><b>] </b>
philpem@5 51 <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/download.shtml">Download</a> <b>]</b>
philpem@5 52 <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/screenshots.shtml">Screenshots</a> <b>]</b>
philpem@5 53 <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/reference/group__cimg__faq.html">FAQ</a> <b>]</b>
philpem@5 54 <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/reference/group__cimg__tutorial.html">Tutorial</a> <b>]</b>
philpem@5 55 <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/reference/index.html">Documentation</a> <b>]</b>
philpem@5 56 <b>[</b> <a target="_parent" href="http://sourceforge.net/forum/forum.php?forum_id=334630">Forum</a> <b>]</b>
philpem@5 57 <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/chat.shtml">Chat</a> <b>]</b>
philpem@5 58 <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/links.shtml">Links</a> <b>]</b>
philpem@5 59 </font>
philpem@5 60 </td></tr></tbody>
philpem@5 61 </table>
philpem@5 62 </center>
philpem@5 63 <hr noshade="noshade" size="1" width="90%"></hr>
philpem@5 64 </td></tr></tbody>
philpem@5 65 </table>
philpem@5 66 <!-- Generated by Doxygen 1.5.7.1 -->
philpem@5 67 <script type="text/javascript">
philpem@5 68 <!--
philpem@5 69 function changeDisplayState (e){
philpem@5 70 var num=this.id.replace(/[^[0-9]/g,'');
philpem@5 71 var button=this.firstChild;
philpem@5 72 var sectionDiv=document.getElementById('dynsection'+num);
philpem@5 73 if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
philpem@5 74 sectionDiv.style.display='block';
philpem@5 75 button.src='open.gif';
philpem@5 76 }else{
philpem@5 77 sectionDiv.style.display='none';
philpem@5 78 button.src='closed.gif';
philpem@5 79 }
philpem@5 80 }
philpem@5 81 function initDynSections(){
philpem@5 82 var divs=document.getElementsByTagName('div');
philpem@5 83 var sectionCounter=1;
philpem@5 84 for(var i=0;i<divs.length-1;i++){
philpem@5 85 if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
philpem@5 86 var header=divs[i];
philpem@5 87 var section=divs[i+1];
philpem@5 88 var button=header.firstChild;
philpem@5 89 if (button!='IMG'){
philpem@5 90 divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
philpem@5 91 button=document.createElement('img');
philpem@5 92 divs[i].insertBefore(button,divs[i].firstChild);
philpem@5 93 }
philpem@5 94 header.style.cursor='pointer';
philpem@5 95 header.onclick=changeDisplayState;
philpem@5 96 header.id='dynheader'+sectionCounter;
philpem@5 97 button.src='closed.gif';
philpem@5 98 section.id='dynsection'+sectionCounter;
philpem@5 99 section.style.display='none';
philpem@5 100 section.style.marginLeft='14px';
philpem@5 101 sectionCounter++;
philpem@5 102 }
philpem@5 103 }
philpem@5 104 }
philpem@5 105 window.onload = initDynSections;
philpem@5 106 -->
philpem@5 107 </script>
philpem@5 108 <div class="navigation" id="top">
philpem@5 109 <div class="tabs">
philpem@5 110 <ul>
philpem@5 111 <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
philpem@5 112 <li><a href="modules.html"><span>Modules</span></a></li>
philpem@5 113 <li><a href="namespaces.html"><span>Namespaces</span></a></li>
philpem@5 114 <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
philpem@5 115 </ul>
philpem@5 116 </div>
philpem@5 117 <div class="tabs">
philpem@5 118 <ul>
philpem@5 119 <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
philpem@5 120 <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
philpem@5 121 <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
philpem@5 122 </ul>
philpem@5 123 </div>
philpem@5 124 <div class="navpath"><a class="el" href="namespacecimg__library.html">cimg_library</a>::<a class="el" href="structcimg__library_1_1CImgException.html">CImgException</a>
philpem@5 125 </div>
philpem@5 126 </div>
philpem@5 127 <div class="contents">
philpem@5 128 <h1>CImgException Struct Reference</h1><!-- doxytag: class="cimg_library::CImgException" -->Instances of this class are thrown when errors occur during a CImg library function call.
philpem@5 129 <a href="#_details">More...</a>
philpem@5 130 <p>
philpem@5 131 Inherited by CImgArgumentException, CImgDisplayException, CImgInstanceException, CImgIOException, and CImgWarningException.
philpem@5 132 <p>
philpem@5 133
philpem@5 134 <p>
philpem@5 135 <a href="structcimg__library_1_1CImgException-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
philpem@5 136 <tr><td></td></tr>
philpem@5 137 <tr><td colspan="2"><br><h2>Public Attributes</h2></td></tr>
philpem@5 138 <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="4698f05956e353cfe926fc59e4b50a2e"></a><!-- doxytag: member="cimg_library::CImgException::message" ref="4698f05956e353cfe926fc59e4b50a2e" args="[1024]" -->
philpem@5 139 char&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structcimg__library_1_1CImgException.html#4698f05956e353cfe926fc59e4b50a2e">message</a> [1024]</td></tr>
philpem@5 140
philpem@5 141 <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Message associated with the error that thrown the exception. <br></td></tr>
philpem@5 142 </table>
philpem@5 143 <hr><a name="_details"></a><h2>Detailed Description</h2>
philpem@5 144 Instances of this class are thrown when errors occur during a CImg library function call.
philpem@5 145 <p>
philpem@5 146 <h2><a class="anchor" name="ex1">
philpem@5 147 Overview</a></h2>
philpem@5 148 <a class="el" href="structcimg__library_1_1CImgException.html" title="Instances of this class are thrown when errors occur during a CImg library function...">CImgException</a> is the base class of CImg exceptions. Exceptions are thrown by the CImg Library when an error occured in a CImg library function call. <a class="el" href="structcimg__library_1_1CImgException.html" title="Instances of this class are thrown when errors occur during a CImg library function...">CImgException</a> is seldom thrown itself. Children classes that specify the kind of error encountered are generally used instead. These sub-classes are :<p>
philpem@5 149 <ul>
philpem@5 150 <li><b>CImgInstanceException</b> : Thrown when the instance associated to the called CImg function is not correctly defined. Generally, this exception is thrown when one tries to process <em>empty</em> images. The example below will throw a <em>CImgInstanceException</em>. <div class="fragment"><pre class="fragment"> CImg&lt;float&gt; img; <span class="comment">// Construct an empty image.</span>
philpem@5 151 img.blur(10); <span class="comment">// Try to blur the image.</span>
philpem@5 152 </pre></div></li></ul>
philpem@5 153 <p>
philpem@5 154 <ul>
philpem@5 155 <li><b>CImgArgumentException</b> : Thrown when one of the arguments given to the called CImg function is not correct. Generally, this exception is thrown when arguments passed to the function are outside an admissible range of values. The example below will throw a <em>CImgArgumentException</em>. <div class="fragment"><pre class="fragment"> CImg&lt;float&gt; img(100,100,1,3); <span class="comment">// Define a 100x100 color image with float pixels.</span>
philpem@5 156 img = 0; <span class="comment">// Try to fill pixels from the 0 pointer (invalid argument to operator=() ).</span>
philpem@5 157 </pre></div></li></ul>
philpem@5 158 <p>
philpem@5 159 <ul>
philpem@5 160 <li><b>CImgIOException</b> : Thrown when an error occured when trying to load or save image files. The example below will throw a <em>CImgIOException</em>. <div class="fragment"><pre class="fragment"> CImg&lt;float&gt; img(<span class="stringliteral">"file_doesnt_exist.jpg"</span>); <span class="comment">// Try to load a file that doesn't exist.</span>
philpem@5 161 </pre></div></li></ul>
philpem@5 162 <p>
philpem@5 163 <ul>
philpem@5 164 <li><b>CImgDisplayException</b> : Thrown when an error occured when trying to display an image in a window. This exception is thrown when image display request cannot be satisfied.</li></ul>
philpem@5 165 <p>
philpem@5 166 The parent class <a class="el" href="structcimg__library_1_1CImgException.html" title="Instances of this class are thrown when errors occur during a CImg library function...">CImgException</a> may be thrown itself when errors that cannot be classified in one of the above type occur. It is recommended not to throw CImgExceptions yourself, since there are normally reserved to CImg Library functions. <b>CImgInstanceException</b>, <b>CImgArgumentException</b>, <b>CImgIOException</b> and <b>CImgDisplayException</b> are simple subclasses of <a class="el" href="structcimg__library_1_1CImgException.html" title="Instances of this class are thrown when errors occur during a CImg library function...">CImgException</a> and are thus not detailled more in this reference documentation.<h2><a class="anchor" name="ex2">
philpem@5 167 Exception handling</a></h2>
philpem@5 168 When an error occurs, the CImg Library first displays the error in a modal window. Then, it throws an instance of the corresponding exception class, generally leading the program to stop (this is the default behavior). You can bypass this default behavior by handling the exceptions yourself, using a code block <code>try { ... } catch() { ... }</code>. In this case, you can avoid the apparition of the modal window, by defining the environment variable <code>cimg_debug</code> to 0 before including the CImg header file. The example below shows how to cleanly handle CImg Library exceptions : <div class="fragment"><pre class="fragment"><span class="preprocessor"> #define cimg_debug 0 // Disable modal window in CImg exceptions.</span>
philpem@5 169 <span class="preprocessor"></span><span class="preprocessor"> #define "CImg.h"</span>
philpem@5 170 <span class="preprocessor"></span> <span class="keywordtype">int</span> main() {
philpem@5 171 <span class="keywordflow">try</span> {
philpem@5 172 ...; <span class="comment">// Here, do what you want.</span>
philpem@5 173 }
philpem@5 174 <span class="keywordflow">catch</span> (CImgInstanceException &amp;e) {
philpem@5 175 std::fprintf(stderr,<span class="stringliteral">"CImg Library Error : %s"</span>,e.message); <span class="comment">// Display your own error message</span>
philpem@5 176 ... <span class="comment">// Do what you want now.</span>
philpem@5 177 }
philpem@5 178 }
philpem@5 179 </pre></div> </div>
philpem@5 180 <hr noshade="noshade" size="1" width="100%">
philpem@5 181 <a href="http://sourceforge.net">
philpem@5 182 <img src="http://sourceforge.net/sflogo.php?group_id=96492&amp;type=3" border="0" height="37" width="125"></img>
philpem@5 183 </a>
philpem@5 184 <!-- Start of StatCounter Code -->
philpem@5 185 <script type="text/javascript" language="javascript">
philpem@5 186 <!--
philpem@5 187 var sc_project=895001;
philpem@5 188 var sc_invisible=1;
philpem@5 189 var sc_partition=7;
philpem@5 190 var sc_security="5ea85181";
philpem@5 191 //-->
philpem@5 192 </script>
philpem@5 193 <script type="text/javascript" language="javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript><a href="http://www.statcounter.com/" target="_blank"><img src="http://c8.statcounter.com/counter.php?sc_project=895001&amp;java=0&amp;security=5ea85181&amp;invisible=1" alt="counter stats" border="0"></a> </noscript>
philpem@5 194 <!-- End of StatCounter Code -->
philpem@5 195 </body>
philpem@5 196 </html>