<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[jpeglib Problem]]></title><description><![CDATA[<p>Servus,<br />
ich versuche schon seit geraumer Zeit ein Programm zu programmieren, dass ein bmp Bild zu einem Jpg konvertiert. Jetzt bin ich auf jpeglib.h gestoßen. Da diese auch für Dev-C++ erhältlich ist, hab ich eigentlich gedacht, dass es keine Probleme geben sollte. Aber als ich dieses Programm kompilierte, stürzte das Programm ab, nachdem ich es ausgeführt hatte:</p>
<pre><code class="language-cpp">#include &lt;stdlib.h&gt;
#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;

//#ifdef INT32
//#undef INT32
//#endif

#include &lt;jpeglib.h&gt;
#pragma comment(lib, &quot;jpeglib.lib&quot;);

int jpegCapture(char* filename, int quality)
{
   HBITMAP hBMP;
   HWND desktopWnd;
   int width;
   int height;
   RECT rc;
   HDC hDC;
   HDC hDCmem;
   int posx;
   int posy;
   unsigned char scanline[1000000000];
   JSAMPROW row_pointer[1];	// pointer to JSAMPLE row[s]

   struct jpeg_compress_struct cinfo;
   struct jpeg_error_mgr jerr;
   FILE * outfile;
   COLORREF pixel;

   // Make capture bitmap
   desktopWnd = GetDesktopWindow();
   GetWindowRect(desktopWnd, &amp;rc);
   width = rc.right - rc.left;
   height = rc.bottom - rc.top;
   hDC = GetDC(desktopWnd);
   hDCmem = CreateCompatibleDC(hDC);
   hBMP = CreateCompatibleBitmap(hDC, width, height);
   if (hBMP == NULL) return -2;
   SelectObject(hDCmem, hBMP);
   BitBlt(hDCmem, 0, 0, width, height, hDC, rc.left, rc.top, SRCCOPY);

   // Compress to JPEG using hDCmem
   cinfo.err = jpeg_std_error(&amp;jerr);
   jpeg_create_compress(&amp;cinfo);
   outfile = fopen(filename, &quot;w+b&quot;);
   if (outfile == NULL) return -1;
   jpeg_stdio_dest(&amp;cinfo, outfile);
   cinfo.image_width = width;
   cinfo.image_height = height;
   cinfo.input_components = 3;
   cinfo.in_color_space = JCS_RGB;
   jpeg_set_defaults(&amp;cinfo);
   if (quality &lt; 0) quality = 0;
   else if(quality &gt; 100) quality = 100;
   jpeg_set_quality(&amp;cinfo, quality, FALSE);
   jpeg_start_compress(&amp;cinfo, TRUE);
   for (posy = 0; posy &lt; height; posy++) {
      for (posx = 0; posx &lt; width; posx++) {
         pixel = GetPixel(hDCmem, posx, posy);
         scanline[posx*3+0] = GetRValue(pixel);
         scanline[posx*3+1] = GetGValue(pixel);
         scanline[posx*3+2] = GetBValue(pixel);
      }
      row_pointer[0] = &amp;scanline[0];
      (void) jpeg_write_scanlines(&amp;cinfo, row_pointer, 1);
   }
   jpeg_finish_compress(&amp;cinfo);

   jpeg_destroy_compress(&amp;cinfo);
   fclose(outfile);
   DeleteDC(hDCmem);
   ReleaseDC(desktopWnd, hDC);
   return 0;
}

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    jpegCapture(&quot;hallo.jpg&quot;,75);
    return 0;
}
</code></pre>
<p>Es liegt an den Funktionen der jpeglib.h, aber was der Fehler ist, weiß ich nicht. Die Funktion hab ich von dieser Website &quot;geklaut&quot;: <a href="http://members.aol.com/OlivThill/savejpg/savejpg1_c.htm" rel="nofollow">http://members.aol.com/OlivThill/savejpg/savejpg1_c.htm</a></p>
<p>Bitte keine &quot;Antworten&quot; in Richtungen: &quot;Warum nimmst du kein GDI+?&quot;<br />
Ich will in C und nicht in C++ programmieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/211775/jpeglib-problem</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 05:23:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/211775.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 27 Apr 2008 13:03:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to jpeglib Problem on Sun, 27 Apr 2008 13:03:42 GMT]]></title><description><![CDATA[<p>Servus,<br />
ich versuche schon seit geraumer Zeit ein Programm zu programmieren, dass ein bmp Bild zu einem Jpg konvertiert. Jetzt bin ich auf jpeglib.h gestoßen. Da diese auch für Dev-C++ erhältlich ist, hab ich eigentlich gedacht, dass es keine Probleme geben sollte. Aber als ich dieses Programm kompilierte, stürzte das Programm ab, nachdem ich es ausgeführt hatte:</p>
<pre><code class="language-cpp">#include &lt;stdlib.h&gt;
#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;

//#ifdef INT32
//#undef INT32
//#endif

#include &lt;jpeglib.h&gt;
#pragma comment(lib, &quot;jpeglib.lib&quot;);

int jpegCapture(char* filename, int quality)
{
   HBITMAP hBMP;
   HWND desktopWnd;
   int width;
   int height;
   RECT rc;
   HDC hDC;
   HDC hDCmem;
   int posx;
   int posy;
   unsigned char scanline[1000000000];
   JSAMPROW row_pointer[1];	// pointer to JSAMPLE row[s]

   struct jpeg_compress_struct cinfo;
   struct jpeg_error_mgr jerr;
   FILE * outfile;
   COLORREF pixel;

   // Make capture bitmap
   desktopWnd = GetDesktopWindow();
   GetWindowRect(desktopWnd, &amp;rc);
   width = rc.right - rc.left;
   height = rc.bottom - rc.top;
   hDC = GetDC(desktopWnd);
   hDCmem = CreateCompatibleDC(hDC);
   hBMP = CreateCompatibleBitmap(hDC, width, height);
   if (hBMP == NULL) return -2;
   SelectObject(hDCmem, hBMP);
   BitBlt(hDCmem, 0, 0, width, height, hDC, rc.left, rc.top, SRCCOPY);

   // Compress to JPEG using hDCmem
   cinfo.err = jpeg_std_error(&amp;jerr);
   jpeg_create_compress(&amp;cinfo);
   outfile = fopen(filename, &quot;w+b&quot;);
   if (outfile == NULL) return -1;
   jpeg_stdio_dest(&amp;cinfo, outfile);
   cinfo.image_width = width;
   cinfo.image_height = height;
   cinfo.input_components = 3;
   cinfo.in_color_space = JCS_RGB;
   jpeg_set_defaults(&amp;cinfo);
   if (quality &lt; 0) quality = 0;
   else if(quality &gt; 100) quality = 100;
   jpeg_set_quality(&amp;cinfo, quality, FALSE);
   jpeg_start_compress(&amp;cinfo, TRUE);
   for (posy = 0; posy &lt; height; posy++) {
      for (posx = 0; posx &lt; width; posx++) {
         pixel = GetPixel(hDCmem, posx, posy);
         scanline[posx*3+0] = GetRValue(pixel);
         scanline[posx*3+1] = GetGValue(pixel);
         scanline[posx*3+2] = GetBValue(pixel);
      }
      row_pointer[0] = &amp;scanline[0];
      (void) jpeg_write_scanlines(&amp;cinfo, row_pointer, 1);
   }
   jpeg_finish_compress(&amp;cinfo);

   jpeg_destroy_compress(&amp;cinfo);
   fclose(outfile);
   DeleteDC(hDCmem);
   ReleaseDC(desktopWnd, hDC);
   return 0;
}

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    jpegCapture(&quot;hallo.jpg&quot;,75);
    return 0;
}
</code></pre>
<p>Es liegt an den Funktionen der jpeglib.h, aber was der Fehler ist, weiß ich nicht. Die Funktion hab ich von dieser Website &quot;geklaut&quot;: <a href="http://members.aol.com/OlivThill/savejpg/savejpg1_c.htm" rel="nofollow">http://members.aol.com/OlivThill/savejpg/savejpg1_c.htm</a></p>
<p>Bitte keine &quot;Antworten&quot; in Richtungen: &quot;Warum nimmst du kein GDI+?&quot;<br />
Ich will in C und nicht in C++ programmieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1498995</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1498995</guid><dc:creator><![CDATA[Felix15]]></dc:creator><pubDate>Sun, 27 Apr 2008 13:03:42 GMT</pubDate></item><item><title><![CDATA[Reply to jpeglib Problem on Sun, 27 Apr 2008 13:05:44 GMT]]></title><description><![CDATA[<p>Warum stellst du die Frage dann im WinAPI Forum wenn es an der jpeglib liegt? Die gehört doch gar nicht zur WinAPI. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1498996</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1498996</guid><dc:creator><![CDATA[falsches forum]]></dc:creator><pubDate>Sun, 27 Apr 2008 13:05:44 GMT</pubDate></item><item><title><![CDATA[Reply to jpeglib Problem on Sun, 27 Apr 2008 13:17:33 GMT]]></title><description><![CDATA[<p>Sorry, aber nach folgenden Beiträgen, war ich mir fast sicher:</p>
<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-95271-and-highlight-is-jpeglib.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-95271-and-highlight-is-jpeglib.html</a><br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-46819-and-highlight-is-jpeglib.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-46819-and-highlight-is-jpeglib.html</a></p>
<p>Bitte verschieben, danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1498999</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1498999</guid><dc:creator><![CDATA[Felix15]]></dc:creator><pubDate>Sun, 27 Apr 2008 13:17:33 GMT</pubDate></item><item><title><![CDATA[Reply to jpeglib Problem on Sun, 27 Apr 2008 13:24:29 GMT]]></title><description><![CDATA[<p>Ein Fehler ist auf jeden Fall hier:</p>
<pre><code class="language-cpp">unsigned char scanline[1000000000];
</code></pre>
<p>Der Stack ist normalerweise nur 1 MB groß.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1499001</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1499001</guid><dc:creator><![CDATA[stack]]></dc:creator><pubDate>Sun, 27 Apr 2008 13:24:29 GMT</pubDate></item><item><title><![CDATA[Reply to jpeglib Problem on Sun, 27 Apr 2008 13:25:25 GMT]]></title><description><![CDATA[<p>is auch völlig überflüssig</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1499002</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1499002</guid><dc:creator><![CDATA[real_rofler]]></dc:creator><pubDate>Sun, 27 Apr 2008 13:25:25 GMT</pubDate></item><item><title><![CDATA[Reply to jpeglib Problem on Sun, 27 Apr 2008 13:26:37 GMT]]></title><description><![CDATA[<p>außerdem den code ohne comments zu rippen ist auch alles andere als intelligent <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_down"
      title=":-1:"
      alt="👎"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1499003</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1499003</guid><dc:creator><![CDATA[real_rofler]]></dc:creator><pubDate>Sun, 27 Apr 2008 13:26:37 GMT</pubDate></item><item><title><![CDATA[Reply to jpeglib Problem on Sun, 27 Apr 2008 13:29:39 GMT]]></title><description><![CDATA[<p>außerdem steht im orignal unsigned char scanline[2000*3]; bist du zu blöd zum kopieren?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1499006</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1499006</guid><dc:creator><![CDATA[rofl]]></dc:creator><pubDate>Sun, 27 Apr 2008 13:29:39 GMT</pubDate></item><item><title><![CDATA[Reply to jpeglib Problem on Sun, 27 Apr 2008 13:39:02 GMT]]></title><description><![CDATA[<p>Danke, das wars. Ich hab das bloß geändert, weil ich einen anderen Fehler hatte und gemeint hab, dass es daran liegen würde.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1499009</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1499009</guid><dc:creator><![CDATA[Felix15]]></dc:creator><pubDate>Sun, 27 Apr 2008 13:39:02 GMT</pubDate></item></channel></rss>