<?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[GetDIBits geht nicht :(]]></title><description><![CDATA[<p>Irgendwie habe ich mal wieder Probleme, die gestern mit demselben Code noch nicht da waren, denn gestern funkionierte dieser Code noch. Soweit ich weiss hab ich nichts daran geändert. Lagen sicher gestern durch Zufall passende Daten in irgendeinem Buffer.</p>
<p>Jedenfalls gibt folgende Funktion immer wieder &quot;Can't get BITMAP BITS (ErrCode: 00000000)&quot; aus. Kann mir jemand sagen, was ich falsch gemacht habe?</p>
<pre><code class="language-cpp">HBITMAP			hBitmap;
HDC				hBitmapDC;
BITMAPINFO		bi;
char *ImageFile;

ImageFile = &quot;C:\bild.bmp&quot;;

printf(&quot;Drucke Bild '%s'\n&quot;, ImageFile);

// Bitmap laden
hBitmapDC	= CreateCompatibleDC( hDC );
hBitmap		= (HBITMAP)LoadImage( NULL, ImageFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
if ( hBitmap == NULL )
{
	printf(&quot;Can't open image\n&quot;);
	return;
}
SelectObject( hBitmapDC, hBitmap );

// Bitmapinfo erhalten
memset		( &amp;bi, 0, sizeof( bi ) );
bi.bmiHeader.biSize		= sizeof( BITMAPINFOHEADER );
if ( GetDIBits( hBitmapDC, hBitmap, 0, 0, NULL, &amp;bi, DIB_RGB_COLORS ) == 0 )
{
	printf(&quot;Can't get BITMAPINFO\n&quot;);
	return;
}
printf(&quot;Image size: %ix%i\n&quot;, bi.bmiHeader.biWidth, bi.bmiHeader.biHeight );

bi.bmiHeader.biSize		= sizeof( BITMAPINFOHEADER );	
void *Bits = malloc( bi.bmiHeader.biWidth * bi.bmiHeader.biHeight * 4 );
if ( GetDIBits( hBitmapDC, hBitmap, 0, bi.bmiHeader.biHeight, Bits, &amp;bi, DIB_RGB_COLORS ) == 0 )
{
	printf(&quot;Can't get BITMAP BITS (ErrCode: %08x)\n&quot;, GetLastError());
	return;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/114528/getdibits-geht-nicht</link><generator>RSS for Node</generator><lastBuildDate>Wed, 01 Jul 2026 23:57:52 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/114528.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 05 Jul 2005 09:34:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GetDIBits geht nicht :( on Tue, 05 Jul 2005 09:34:26 GMT]]></title><description><![CDATA[<p>Irgendwie habe ich mal wieder Probleme, die gestern mit demselben Code noch nicht da waren, denn gestern funkionierte dieser Code noch. Soweit ich weiss hab ich nichts daran geändert. Lagen sicher gestern durch Zufall passende Daten in irgendeinem Buffer.</p>
<p>Jedenfalls gibt folgende Funktion immer wieder &quot;Can't get BITMAP BITS (ErrCode: 00000000)&quot; aus. Kann mir jemand sagen, was ich falsch gemacht habe?</p>
<pre><code class="language-cpp">HBITMAP			hBitmap;
HDC				hBitmapDC;
BITMAPINFO		bi;
char *ImageFile;

ImageFile = &quot;C:\bild.bmp&quot;;

printf(&quot;Drucke Bild '%s'\n&quot;, ImageFile);

// Bitmap laden
hBitmapDC	= CreateCompatibleDC( hDC );
hBitmap		= (HBITMAP)LoadImage( NULL, ImageFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
if ( hBitmap == NULL )
{
	printf(&quot;Can't open image\n&quot;);
	return;
}
SelectObject( hBitmapDC, hBitmap );

// Bitmapinfo erhalten
memset		( &amp;bi, 0, sizeof( bi ) );
bi.bmiHeader.biSize		= sizeof( BITMAPINFOHEADER );
if ( GetDIBits( hBitmapDC, hBitmap, 0, 0, NULL, &amp;bi, DIB_RGB_COLORS ) == 0 )
{
	printf(&quot;Can't get BITMAPINFO\n&quot;);
	return;
}
printf(&quot;Image size: %ix%i\n&quot;, bi.bmiHeader.biWidth, bi.bmiHeader.biHeight );

bi.bmiHeader.biSize		= sizeof( BITMAPINFOHEADER );	
void *Bits = malloc( bi.bmiHeader.biWidth * bi.bmiHeader.biHeight * 4 );
if ( GetDIBits( hBitmapDC, hBitmap, 0, bi.bmiHeader.biHeight, Bits, &amp;bi, DIB_RGB_COLORS ) == 0 )
{
	printf(&quot;Can't get BITMAP BITS (ErrCode: %08x)\n&quot;, GetLastError());
	return;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/824058</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/824058</guid><dc:creator><![CDATA[ProfEich]]></dc:creator><pubDate>Tue, 05 Jul 2005 09:34:26 GMT</pubDate></item></channel></rss>