Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 4f45e7bdfd4a5ff17f5f8eaab90d017f > files > 1450

albumshaper-2.1-6mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>AlbumShaper: pointillism.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>pointillism.h File Reference</h1>
<p>
<div class="dynheader">
This graph shows which files directly or indirectly include this file:</div>
<div class="dynsection">
</div>

<p>
<a href="pointillism_8h_source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">QImage *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="pointillism_8h.html#34b6840048618481c95bfcd7dd5892c3">pointillismEffect</a> (QString filename, <a class="el" href="classManipulationOptions.html">ManipulationOptions</a> *options)</td></tr>

</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="34b6840048618481c95bfcd7dd5892c3"></a><!-- doxytag: member="pointillism.h::pointillismEffect" ref="34b6840048618481c95bfcd7dd5892c3" args="(QString filename, ManipulationOptions *options)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">QImage* pointillismEffect           </td>
          <td>(</td>
          <td class="paramtype">QString&nbsp;</td>
          <td class="paramname"> <em>filename</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classManipulationOptions.html">ManipulationOptions</a> *&nbsp;</td>
          <td class="paramname"> <em>options</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>

<p>Definition at line <a class="el" href="pointillism_8cpp_source.html#l00109">109</a> of file <a class="el" href="pointillism_8cpp_source.html">pointillism.cpp</a>.</p>

<p>References <a class="el" href="blackWhite_8cpp_source.html#l00060">blackWhiteEffect()</a>, <a class="el" href="pointillism_8cpp_source.html#l00067">computeLocalGrayVal()</a>, <a class="el" href="pointillism_8cpp_source.html#l00098">drawDotAt()</a>, <a class="el" href="redEye__internal_8h_source.html#l00037">editedImage</a>, <a class="el" href="blur_8cpp_source.html#l00079">height</a>, <a class="el" href="pointillism_8cpp_source.html#l00042">pickRandomPixelWithinBlock()</a>, and <a class="el" href="blur_8cpp_source.html#l00079">width</a>.</p>

<p>Referenced by <a class="el" href="editingInterface_8cpp_source.html#l00834">EditingInterface::applyEffect()</a>.</p>
<div class="fragment"><pre class="fragment"><a name="l00110"></a>00110 {
<a name="l00111"></a>00111   <span class="comment">//intialize seed using current time</span>
<a name="l00112"></a>00112   srand( <span class="keywordtype">unsigned</span>(time(NULL)) );
<a name="l00113"></a>00113 
<a name="l00114"></a>00114   <span class="comment">//load original image and convert to grayscale</span>
<a name="l00115"></a>00115   QImage* originalImage = <a class="code" href="blackWhite_8cpp.html#81188751080c22115720554f1ce6a30f">blackWhiteEffect</a>( filename, NULL );
<a name="l00116"></a>00116   
<a name="l00117"></a>00117   <span class="comment">//construct edited image</span>
<a name="l00118"></a>00118   QImage* <a class="code" href="redEye__internal_8h.html#63116a8b94b4ed0e99ddcb7f6f3bd919">editedImage</a> = <span class="keyword">new</span> QImage( originalImage-&gt;width(),
<a name="l00119"></a>00119                                     originalImage-&gt;height(),
<a name="l00120"></a>00120                                     originalImage-&gt;depth() );
<a name="l00121"></a>00121 
<a name="l00122"></a>00122   <span class="comment">//fill with white since we'll be drawing black/color dots on top</span>
<a name="l00123"></a>00123   editedImage-&gt;fill( qRgb(255,255,255) );
<a name="l00124"></a>00124 
<a name="l00125"></a>00125   <span class="comment">//break image into BLOCK_SIZE x BLOCK_SIZE blocks. iterate over</span>
<a name="l00126"></a>00126   <span class="comment">//each block and pick a random pixel within. Local</span>
<a name="l00127"></a>00127   <span class="comment">//average gray value in edited image is &gt; originalImage + thresh</span>
<a name="l00128"></a>00128   <span class="comment">//then draw a dot at pixel. continue doing this for each block</span>
<a name="l00129"></a>00129   <span class="comment">//and repeat until ???</span>
<a name="l00130"></a>00130   <span class="keyword">const</span> <span class="keywordtype">int</span> BLOCK_SIZE = 8;
<a name="l00131"></a>00131 
<a name="l00132"></a>00132   <span class="comment">//compute image size in blocks</span>
<a name="l00133"></a>00133   <span class="keywordtype">int</span> blocksWide = editedImage-&gt;width() / BLOCK_SIZE;
<a name="l00134"></a>00134   <span class="keywordflow">if</span>(blocksWide*BLOCK_SIZE &lt; editedImage-&gt;<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>())
<a name="l00135"></a>00135   { blocksWide++; }
<a name="l00136"></a>00136   
<a name="l00137"></a>00137   <span class="keywordtype">int</span> blocksTall = editedImage-&gt;height() / BLOCK_SIZE;
<a name="l00138"></a>00138   <span class="keywordflow">if</span>(blocksTall*BLOCK_SIZE &lt; editedImage-&gt;<a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>())
<a name="l00139"></a>00139   { blocksTall++; }
<a name="l00140"></a>00140 
<a name="l00141"></a>00141   <span class="comment">//iterate over image say 100 times, we'll need to fix this outer loop to be smarter?</span>
<a name="l00142"></a>00142   <span class="keywordtype">int</span> bx,by,x,y;
<a name="l00143"></a>00143   <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i&lt;10; i++)
<a name="l00144"></a>00144   {
<a name="l00145"></a>00145     <span class="comment">//iterate over all blocks</span>
<a name="l00146"></a>00146     <span class="keywordflow">for</span>(bx=0; bx&lt;blocksWide; bx++)
<a name="l00147"></a>00147     {
<a name="l00148"></a>00148       <span class="keywordflow">for</span>(by=0; by&lt;blocksTall; by++)
<a name="l00149"></a>00149       {
<a name="l00150"></a>00150         <span class="comment">//pick random pixel within block</span>
<a name="l00151"></a>00151         <a class="code" href="pointillism_8cpp.html#3bcd2957d75fcb33f41acca28c8bbc63">pickRandomPixelWithinBlock</a>( editedImage-&gt;width(),
<a name="l00152"></a>00152                                     editedImage-&gt;height(),
<a name="l00153"></a>00153                                     bx, by,
<a name="l00154"></a>00154                                     BLOCK_SIZE,
<a name="l00155"></a>00155                                     x, y );
<a name="l00156"></a>00156         
<a name="l00157"></a>00157         <span class="keywordtype">double</span> curGrayVal = <a class="code" href="pointillism_8cpp.html#3899ac9e3314758c9e2531f614675f37">computeLocalGrayVal</a>( editedImage, x, y );
<a name="l00158"></a>00158         <span class="keywordtype">double</span> goalGrayVal = <a class="code" href="pointillism_8cpp.html#3899ac9e3314758c9e2531f614675f37">computeLocalGrayVal</a>( originalImage, x, y );
<a name="l00159"></a>00159 
<a name="l00160"></a>00160         <span class="comment">//too bright -&gt; draw dot</span>
<a name="l00161"></a>00161         <span class="keywordflow">if</span>( curGrayVal &gt; goalGrayVal )
<a name="l00162"></a>00162         { <a class="code" href="pointillism_8cpp.html#81f112ac02150cd015a661348261aa4a">drawDotAt</a>( editedImage, x, y, 5 ); }
<a name="l00163"></a>00163       }
<a name="l00164"></a>00164     }
<a name="l00165"></a>00165   }
<a name="l00166"></a>00166 
<a name="l00167"></a>00167   <span class="comment">//free grayscale form of original image</span>
<a name="l00168"></a>00168   <span class="keyword">delete</span> originalImage;
<a name="l00169"></a>00169   originalImage = NULL;
<a name="l00170"></a>00170   
<a name="l00171"></a>00171   <span class="comment">//return pointer to edited image</span>
<a name="l00172"></a>00172   <span class="keywordflow">return</span> editedImage;      
<a name="l00173"></a>00173 }
</pre></div>
<p>

</div>
</div><p>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Aug 23 02:34:31 2009 for AlbumShaper by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>