1.1 diff -r 5edfbd3e7a46 -r 1204ebf9340d PTdecode/CImg-1.3.0/html/reference/group__cimg__options.html 1.2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 +++ b/PTdecode/CImg-1.3.0/html/reference/group__cimg__options.html Mon Aug 03 14:09:20 2009 +0100 1.4 @@ -0,0 +1,197 @@ 1.5 + xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 1.6 +<head> 1.7 +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></meta> 1.8 +<title>The CImg Library - C++ Template Image Processing Toolkit</title> 1.9 +<meta content="David Tschumperle" name="author"></meta> 1.10 +<link rel="shortcut icon" type="image/x-icon" href="http://cimg.sourceforge.net/favicon.ico"></link> 1.11 +<link rel="icon" type="image/png" href="favicon.png"></link> 1.12 +<link href="doxygen.css" rel="stylesheet" type="text/css"> 1.13 +<link href="tabs.css" rel="stylesheet" type="text/css"> 1.14 +<style type="text/css"> 1.15 +<!-- 1.16 +body {background-color:white; font-family:sans-serif; } 1.17 +a:active{text-decoration:none; color:#303090} 1.18 +a:link{text-decoration:none; color:#303090} 1.19 +a:visited{text-decoration:none; color:#303090} 1.20 +a:hover{text-decoration:underline; color:#4E9F71} 1.21 +--> 1.22 +</style> 1.23 +<script language="JavaScript" type="text/javascript"> 1.24 + <!-- Original: Eric King (eric_andrew_king@hotmail.com) is used to display images in popup windows --> 1.25 + <!-- Web Site: http://redrival.com/eak/ --> 1.26 + <!-- This script and many more are available free online at --> 1.27 + <!-- The JavaScript Source!! http://javascript.internet.com --> 1.28 + <!-- Begin 1.29 + function NewWindow(mypage, myname, w, h, scroll) { 1.30 + var winl = (screen.width - w) / 2; 1.31 + var wint = (screen.height - h) / 2; 1.32 + winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable' 1.33 + win = window.open(mypage, myname, winprops) 1.34 + if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } 1.35 + } 1.36 + // End --> 1.37 +</script> 1.38 +</head> 1.39 +<body> 1.40 + <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%"> 1.41 + <tbody><tr><td> 1.42 + <hr noshade="noshade" size="1" width="90%"></hr> 1.43 + <center> 1.44 + <br/> 1.45 + <a href="http://cimg.sourceforge.net"><img src="http://cimg.sourceforge.net/img/CImgLogo.jpg" alt="" border="0"></img></a><br/> 1.46 + <br/> 1.47 + </center> 1.48 + <hr noshade="noshade" size="1" width="90%"></hr> 1.49 + <center> 1.50 + <table bgcolor="#EEEEFF" style="width: 90%; text-align: left; margin-left: auto; margin-right: auto;" border="0" cellpadding="3" cellspacing="0"> 1.51 + <tbody><tr><td style="text-align: center; vertical-align: top;"> 1.52 + <font color="#FFFFFF" face="Arial,Helvetica" size="-1"> 1.53 + <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/index.shtml">Main</a> <b>]</b> 1.54 + <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/news.shtml">News</a><b>] </b> 1.55 + <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/download.shtml">Download</a> <b>]</b> 1.56 + <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/screenshots.shtml">Screenshots</a> <b>]</b> 1.57 + <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/reference/group__cimg__faq.html">FAQ</a> <b>]</b> 1.58 + <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/reference/group__cimg__tutorial.html">Tutorial</a> <b>]</b> 1.59 + <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/reference/index.html">Documentation</a> <b>]</b> 1.60 + <b>[</b> <a target="_parent" href="http://sourceforge.net/forum/forum.php?forum_id=334630">Forum</a> <b>]</b> 1.61 + <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/chat.shtml">Chat</a> <b>]</b> 1.62 + <b>[</b> <a target="_parent" href="http://cimg.sourceforge.net/links.shtml">Links</a> <b>]</b> 1.63 + </font> 1.64 + </td></tr></tbody> 1.65 + </table> 1.66 + </center> 1.67 + <hr noshade="noshade" size="1" width="90%"></hr> 1.68 + </td></tr></tbody> 1.69 +</table> 1.70 +<!-- Generated by Doxygen 1.5.7.1 --> 1.71 +<script type="text/javascript"> 1.72 +<!-- 1.73 +function changeDisplayState (e){ 1.74 + var num=this.id.replace(/[^[0-9]/g,''); 1.75 + var button=this.firstChild; 1.76 + var sectionDiv=document.getElementById('dynsection'+num); 1.77 + if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){ 1.78 + sectionDiv.style.display='block'; 1.79 + button.src='open.gif'; 1.80 + }else{ 1.81 + sectionDiv.style.display='none'; 1.82 + button.src='closed.gif'; 1.83 + } 1.84 +} 1.85 +function initDynSections(){ 1.86 + var divs=document.getElementsByTagName('div'); 1.87 + var sectionCounter=1; 1.88 + for(var i=0;i<divs.length-1;i++){ 1.89 + if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){ 1.90 + var header=divs[i]; 1.91 + var section=divs[i+1]; 1.92 + var button=header.firstChild; 1.93 + if (button!='IMG'){ 1.94 + divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild); 1.95 + button=document.createElement('img'); 1.96 + divs[i].insertBefore(button,divs[i].firstChild); 1.97 + } 1.98 + header.style.cursor='pointer'; 1.99 + header.onclick=changeDisplayState; 1.100 + header.id='dynheader'+sectionCounter; 1.101 + button.src='closed.gif'; 1.102 + section.id='dynsection'+sectionCounter; 1.103 + section.style.display='none'; 1.104 + section.style.marginLeft='14px'; 1.105 + sectionCounter++; 1.106 + } 1.107 + } 1.108 +} 1.109 +window.onload = initDynSections; 1.110 +--> 1.111 +</script> 1.112 +<div class="navigation" id="top"> 1.113 + <div class="tabs"> 1.114 + <ul> 1.115 + <li><a href="index.html"><span>Main Page</span></a></li> 1.116 + <li><a href="modules.html"><span>Modules</span></a></li> 1.117 + <li><a href="namespaces.html"><span>Namespaces</span></a></li> 1.118 + <li><a href="annotated.html"><span>Classes</span></a></li> 1.119 + </ul> 1.120 + </div> 1.121 +</div> 1.122 +<div class="contents"> 1.123 +<h1>Retrieving Command Line Arguments.</h1><table border="0" cellpadding="0" cellspacing="0"> 1.124 +<tr><td></td></tr> 1.125 +</table> 1.126 +The CImg library offers facilities to retrieve command line arguments in a console-based program, as it is a commonly needed operation. Three macros <code>cimg_usage()</code>, <code>cimg_help()</code> and <code>cimg_option()</code> are defined for this purpose. Using these macros allows to easily retrieve options values from the command line. Invoking the compiled executable with the option <code>-h</code> or <code>--help</code> will automatically display the program usage, followed by the list of requested options.<h2><a class="anchor" name="so1"> 1.127 +The cimg_usage() macro</a></h2> 1.128 +The macro <code>cimg_usage(usage)</code> may be used to describe the program goal and usage. It is generally inserted one time after the <code>int main(int argc,char **argv)</code> definition.<p> 1.129 +<dl compact><dt><b>Parameters:</b></dt><dd> 1.130 + <table border="0" cellspacing="2" cellpadding="0"> 1.131 + <tr><td valign="top"></td><td valign="top"><em>usage</em> </td><td>: A string describing the program goal and usage. </td></tr> 1.132 + </table> 1.133 +</dl> 1.134 +<dl class="pre" compact><dt><b>Precondition:</b></dt><dd>The function where <code>cimg_usage()</code> is used must have correctly defined <code>argc</code> and <code>argv</code> variables.</dd></dl> 1.135 +<h2><a class="anchor" name="so1_5"> 1.136 +The cimg_help() macro</a></h2> 1.137 +The macro <code>cimg_help(str)</code> will display the string <code>str</code> only if the <code>-help</code> or <code>--help</code> option are invoked when running the programm.<h2><a class="anchor" name="so2"> 1.138 +The cimg_option() macro</a></h2> 1.139 +The macro <code>cimg_option(name,default,usage)</code> may be used to retrieve an option value from the command line.<p> 1.140 +<dl compact><dt><b>Parameters:</b></dt><dd> 1.141 + <table border="0" cellspacing="2" cellpadding="0"> 1.142 + <tr><td valign="top"></td><td valign="top"><em>name</em> </td><td>: The name of the option to be retrieved from the command line. </td></tr> 1.143 + <tr><td valign="top"></td><td valign="top"><em>default</em> </td><td>: The default value returned by the macro if no options <code>name</code> has been specified when running the program. </td></tr> 1.144 + <tr><td valign="top"></td><td valign="top"><em>usage</em> </td><td>: A brief explanation of the option. If <code>usage==0</code>, the option won't appear on the option list when invoking the executable with options <code>-h</code> or <code>--help</code> (hidden option).</td></tr> 1.145 + </table> 1.146 +</dl> 1.147 +<dl class="return" compact><dt><b>Returns:</b></dt><dd><code>cimg_option()</code> returns an object that has the <em>same</em> <em>type</em> than the default value <code>default</code>. The return value is equal to the one specified on the command line. If no such option have been specified, the return value is equal to the default value <code>default</code>. Warning, this can be confusing in some situations (look at the end of the next section). </dd></dl> 1.148 +<dl class="pre" compact><dt><b>Precondition:</b></dt><dd>The function where <code>cimg_option()</code> is used must have correctly defined <code>argc</code> and <code>argv</code> variables.</dd></dl> 1.149 +<h2><a class="anchor" name="so3"> 1.150 +Example of use</a></h2> 1.151 +The code below uses the macros <code>cimg_usage()</code> and <code>cimg_option()</code>. It loads an image, smoothes it an quantifies it with a specified number of values. <div class="fragment"><pre class="fragment"><span class="preprocessor"> #include "CImg.h"</span> 1.152 + <span class="keyword">using namespace </span>cimg_library; 1.153 + <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc,<span class="keywordtype">char</span> **argv) { 1.154 + cimg_usage(<span class="stringliteral">"Retrieve command line arguments"</span>); 1.155 + <span class="keyword">const</span> <span class="keywordtype">char</span>* filename = cimg_option(<span class="stringliteral">"-i"</span>,<span class="stringliteral">"image.gif"</span>,<span class="stringliteral">"Input image file"</span>); 1.156 + <span class="keyword">const</span> <span class="keywordtype">char</span>* output = cimg_option(<span class="stringliteral">"-o"</span>,(<span class="keywordtype">char</span>*)0,<span class="stringliteral">"Output image file"</span>); 1.157 + <span class="keyword">const</span> <span class="keywordtype">double</span> sigma = cimg_option(<span class="stringliteral">"-s"</span>,1.0,<span class="stringliteral">"Standard variation of the gaussian smoothing"</span>); 1.158 + <span class="keyword">const</span> <span class="keywordtype">int</span> nblevels = cimg_option(<span class="stringliteral">"-n"</span>,16,<span class="stringliteral">"Number of quantification levels"</span>); 1.159 + <span class="keyword">const</span> <span class="keywordtype">bool</span> hidden = cimg_option(<span class="stringliteral">"-hidden"</span>,<span class="keyword">false</span>,0); <span class="comment">// This is a hidden option</span> 1.160 + 1.161 + CImg<unsigned char> img(filename); 1.162 + img.blur(sigma).quantize(nblevels); 1.163 + <span class="keywordflow">if</span> (output) img.save(output); <span class="keywordflow">else</span> img.display(<span class="stringliteral">"Output image"</span>); 1.164 + <span class="keywordflow">if</span> (hidden) std::fprintf(stderr,<span class="stringliteral">"You found me !\n"</span>); 1.165 + <span class="keywordflow">return</span> 0; 1.166 + } 1.167 +</pre></div><p> 1.168 +Invoking the corresponding executable with <code>test -h -hidden -n 20 -i foo.jpg</code> will display : <div class="fragment"><pre class="fragment"> 1.169 + ./test -h -hidden -n 20 -i foo.jpg 1.170 + 1.171 + test : Retrieve command line arguments (Oct 16 2004, 12:34:26) 1.172 + 1.173 + -i = foo.jpg : Input image file 1.174 + -o = 0 : Output image file 1.175 + -s = 1 : Standard variation of the gaussian smoothing 1.176 + -n = 20 : Number of quantification levels 1.177 + 1.178 + You found me ! 1.179 +</pre></div><p> 1.180 +<dl class="warning" compact><dt><b>Warning:</b></dt><dd>As the type of object returned by the macro <code>cimg_option(option,default,usage)</code> is defined by the type of <code>default</code>, undesired casts may appear when writting code such as : <div class="fragment"><pre class="fragment"> <span class="keyword">const</span> <span class="keywordtype">double</span> sigma = cimg_option(<span class="stringliteral">"-val"</span>,0,<span class="stringliteral">"A floating point value"</span>); 1.181 +</pre></div> In this case, <code>sigma</code> will always be equal to an integer (since the default value <code>0</code> is an integer). When passing a float value on the command line, a <em>float</em> <em>to</em> <em>integer</em> cast is then done, truncating the given parameter to an integer value (this is surely not a desired behavior). You must specify <code>0.0</code> as the default value in this case.</dd></dl> 1.182 +<h2><a class="anchor" name="so4"> 1.183 +How to learn more about command line options ?</a></h2> 1.184 +You should take a look at the examples <code>examples/gmic.cpp</code> provided in the CImg Library package. This is a command line based image converter which intensively uses the <code>cimg_option()</code> and <code>cimg_usage()</code> macros to retrieve command line parameters. </div> 1.185 +<hr noshade="noshade" size="1" width="100%"> 1.186 +<a href="http://sourceforge.net"> 1.187 +<img src="http://sourceforge.net/sflogo.php?group_id=96492&type=3" border="0" height="37" width="125"></img> 1.188 +</a> 1.189 +<!-- Start of StatCounter Code --> 1.190 +<script type="text/javascript" language="javascript"> 1.191 +<!-- 1.192 +var sc_project=895001; 1.193 +var sc_invisible=1; 1.194 +var sc_partition=7; 1.195 +var sc_security="5ea85181"; 1.196 +//--> 1.197 +</script> 1.198 +<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&java=0&security=5ea85181&invisible=1" alt="counter stats" border="0"></a> </noscript> 1.199 +<!-- End of StatCounter Code --> 1.200 +</body> 1.201 +</html>