<?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]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte mit der Funktion GetDIBits die RGB Werte eines Bitmaps in einem Array speichern. Ich probiere es schon seit etlichen Tagen aber es funktioniert einfach nicht.</p>
<pre><code class="language-cpp">CPaintDC dc(this);

unsigned char *MeinArray;
BITMAPINFO bmpInfo;

CDib dib;
     dib.CreateBitmapArray(dc, bmpInfo, MeinArray);

bool CDib::CreateBitmapArray(CDC &amp;dc, 
							 BITMAPINFO &amp;bmpInfo, 
							 unsigned char* &amp;pArray)
{
	// Variablen deklarieren
	HBITMAP memBitmap;
	CDC		memDC;

	// Bitmapheader
    bmpInfo.bmiHeader.biBitCount    = 24;
    bmpInfo.bmiHeader.biCompression = BI_RGB;
    bmpInfo.bmiHeader.biPlanes      = 1;
    bmpInfo.bmiHeader.biSize        = sizeof(bmpInfo.bmiHeader);
    bmpInfo.bmiHeader.biWidth       = ((rcBounds.left + rcBounds.right) / 4) * 4 + 4;
    bmpInfo.bmiHeader.biHeight      = rcBounds.top + rcBounds.bottom + 1;

	memDC.CreateCompatibleDC(&amp;dc);

	// DIB - Sektion erzeugen
    memBitmap = CreateDIBSection(memDC,
                                 &amp;bmpInfo,
                                 DIB_RGB_COLORS,
                                 0, 0, 0);

	memDC.SelectObject(memBitmap);

    memDC.BitBlt(0, 
				 0, 
				 bmpInfo.bmiHeader.biWidth, 
				 bmpInfo.bmiHeader.biHeight, 
                 &amp;dc, 
				 rcBounds.left, 
				 rcBounds.top, 
				 SRCCOPY);

    pArray = new unsigned char[bmpInfo.bmiHeader.biWidth * bmpInfo.bmiHeader.biHeight * 3]; 

	// Gerätekontextunabhängige Bitmap in ByteArrays kopieren
    if(GetDIBits(dc, 
			  memBitmap, 
			  0, 
			  bmpInfo.bmiHeader.biHeight, 
			  pArray,
			  &amp;bmpInfo, 
			  DIB_RGB_COLORS))
	{	
		return true;
	}
	else
	{
		return false;
	}
</code></pre>
<p>Aber warum funktioniert das nicht ?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/54938/getdibits</link><generator>RSS for Node</generator><lastBuildDate>Mon, 01 Jun 2026 22:11:52 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/54938.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 12 Nov 2003 10:28:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GetDIBits on Wed, 12 Nov 2003 10:28:42 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte mit der Funktion GetDIBits die RGB Werte eines Bitmaps in einem Array speichern. Ich probiere es schon seit etlichen Tagen aber es funktioniert einfach nicht.</p>
<pre><code class="language-cpp">CPaintDC dc(this);

unsigned char *MeinArray;
BITMAPINFO bmpInfo;

CDib dib;
     dib.CreateBitmapArray(dc, bmpInfo, MeinArray);

bool CDib::CreateBitmapArray(CDC &amp;dc, 
							 BITMAPINFO &amp;bmpInfo, 
							 unsigned char* &amp;pArray)
{
	// Variablen deklarieren
	HBITMAP memBitmap;
	CDC		memDC;

	// Bitmapheader
    bmpInfo.bmiHeader.biBitCount    = 24;
    bmpInfo.bmiHeader.biCompression = BI_RGB;
    bmpInfo.bmiHeader.biPlanes      = 1;
    bmpInfo.bmiHeader.biSize        = sizeof(bmpInfo.bmiHeader);
    bmpInfo.bmiHeader.biWidth       = ((rcBounds.left + rcBounds.right) / 4) * 4 + 4;
    bmpInfo.bmiHeader.biHeight      = rcBounds.top + rcBounds.bottom + 1;

	memDC.CreateCompatibleDC(&amp;dc);

	// DIB - Sektion erzeugen
    memBitmap = CreateDIBSection(memDC,
                                 &amp;bmpInfo,
                                 DIB_RGB_COLORS,
                                 0, 0, 0);

	memDC.SelectObject(memBitmap);

    memDC.BitBlt(0, 
				 0, 
				 bmpInfo.bmiHeader.biWidth, 
				 bmpInfo.bmiHeader.biHeight, 
                 &amp;dc, 
				 rcBounds.left, 
				 rcBounds.top, 
				 SRCCOPY);

    pArray = new unsigned char[bmpInfo.bmiHeader.biWidth * bmpInfo.bmiHeader.biHeight * 3]; 

	// Gerätekontextunabhängige Bitmap in ByteArrays kopieren
    if(GetDIBits(dc, 
			  memBitmap, 
			  0, 
			  bmpInfo.bmiHeader.biHeight, 
			  pArray,
			  &amp;bmpInfo, 
			  DIB_RGB_COLORS))
	{	
		return true;
	}
	else
	{
		return false;
	}
</code></pre>
<p>Aber warum funktioniert das nicht ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/392337</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/392337</guid><dc:creator><![CDATA[Ronny W]]></dc:creator><pubDate>Wed, 12 Nov 2003 10:28:42 GMT</pubDate></item><item><title><![CDATA[Reply to GetDIBits on Wed, 12 Nov 2003 10:30:49 GMT]]></title><description><![CDATA[<p>Sorry das rcBounds ist natürlich auch noch ein Parameter der Funktion CreateBitmapArray(..., const CRect &amp;rcBounds)</p>
<p>Gruß Ronny</p>
]]></description><link>https://www.c-plusplus.net/forum/post/392340</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/392340</guid><dc:creator><![CDATA[Ronny W]]></dc:creator><pubDate>Wed, 12 Nov 2003 10:30:49 GMT</pubDate></item></channel></rss>