<div dir="ltr">Hi All,<br><br>I have some code that read .pnm file with fgets and had it into buffer, Can I change it to read my desktop:<br><br><pre><div class="line" id="LC29"> <span class="k">if</span><span class="p">(</span><span class="n">argc</span><span class="o">></span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span></div>
<div class="line" id="LC30"> <span class="n">in</span><span class="o">=</span><span class="n">fopen</span><span class="p">(</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="s">"rb"</span><span class="p">);</span></div>
<div class="line" id="LC31"> <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="n">in</span><span class="p">)</span> <span class="p">{</span></div><div class="line" id="LC32"> <span class="n">printf</span><span class="p">(</span><span class="s">"Couldn't find file %s.</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">]);</span></div>
<div class="line" id="LC33"> <span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span></div><div class="line" id="LC34"> <span class="p">}<br></span><div class="line" id="LC37">
<span class="n">fgets</span><span class="p">(</span><span class="n">buffer</span><span class="p">,</span><span class="mi">1024</span><span class="p">,</span><span class="n">in</span><span class="p">);</span></div><div class="line" id="LC38">
<span class="k">if</span><span class="p">(</span><span class="n">strncmp</span><span class="p">(</span><span class="n">buffer</span><span class="p">,</span><span class="s">"P6"</span><span class="p">,</span><span class="mi">2</span><span class="p">))</span> <span class="p">{</span></div>
<div class="line" id="LC39"> <span class="n">printf</span><span class="p">(</span><span class="s">"Not a ppm.</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span></div><div class="line" id="LC40">
<span class="n">exit</span><span class="p">(</span><span class="mi">2</span><span class="p">);<br><br>I want to use this code and had it into buffer:<br><br>cairo_surface_write_to_png(cairo_xlib_surface_create(dpy,<br>
DefaultRootWindow(dpy), DefaultVisual(dpy, DefaultScreen(dpy)),<br> 400, 400), /* a lie */<br> "out.png")<br><br>any idea please?<br><br>Best Regards<br>Gadi<br></span></div><br></div>
</pre><br></div>