<?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[BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich]]></title><description><![CDATA[<p>Hi,</p>
<p>ich will über die Pixel eines BITMAP iterieren, dafür brauche ich es im DC:</p>
<pre><code>HDC hDC = GetDC( NULL ) ;
	HDC bmpDC = CreateCompatibleDC(hDC);

	SelectObject(bmpDC, bmp); 
	cout &lt;&lt; &quot;Pixel: &quot; &lt;&lt; GetPixel(bmpDC, 1, 1) &lt;&lt; &quot;\n&quot;;
	cout &lt;&lt; &quot;Pixel: &quot; &lt;&lt; GetPixel(bmpDC, 1, 1) &lt;&lt; &quot;\n&quot;;
</code></pre>
<p>Ich bekomme aber den Fehler:</p>
<pre><code>error C2664: 'SelectObject': Konvertierung des Parameters 2 von 'BITMAP' in 'HGDIOBJ' nicht möglich
        Kein benutzerdefinierter Konvertierungsoperator verfügbar, der diese Konvertierung durchführen kann, oder der Operator kann nicht aufgerufen werden
</code></pre>
<p>Hat jemand einen Tipp für mich?</p>
<p>Gruß<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/215778/bitmap-in-hgdiobj-nicht-möglich</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 23:25:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/215778.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 15 Jun 2008 13:06:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Sun, 15 Jun 2008 13:34:32 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich will über die Pixel eines BITMAP iterieren, dafür brauche ich es im DC:</p>
<pre><code>HDC hDC = GetDC( NULL ) ;
	HDC bmpDC = CreateCompatibleDC(hDC);

	SelectObject(bmpDC, bmp); 
	cout &lt;&lt; &quot;Pixel: &quot; &lt;&lt; GetPixel(bmpDC, 1, 1) &lt;&lt; &quot;\n&quot;;
	cout &lt;&lt; &quot;Pixel: &quot; &lt;&lt; GetPixel(bmpDC, 1, 1) &lt;&lt; &quot;\n&quot;;
</code></pre>
<p>Ich bekomme aber den Fehler:</p>
<pre><code>error C2664: 'SelectObject': Konvertierung des Parameters 2 von 'BITMAP' in 'HGDIOBJ' nicht möglich
        Kein benutzerdefinierter Konvertierungsoperator verfügbar, der diese Konvertierung durchführen kann, oder der Operator kann nicht aufgerufen werden
</code></pre>
<p>Hat jemand einen Tipp für mich?</p>
<p>Gruß<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1529470</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1529470</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Sun, 15 Jun 2008 13:34:32 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Sun, 15 Jun 2008 14:43:26 GMT]]></title><description><![CDATA[<p>Benutzt Du LoadImage um das Bitmap zu laden ?</p>
<p>Wenn ja, dann müsstest Du ein HGDIOBJ erhalten ...</p>
<p>ansonsten Typumwandlung ...</p>
<pre><code class="language-cpp">SelectObject(bmpDC, (HGDIOBJ) bmp);
</code></pre>
<p>oder</p>
<pre><code class="language-cpp">(HGDIOBJ) LoadBitmap(...);
</code></pre>
<p>Gruß<br />
Greenhorn</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1529531</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1529531</guid><dc:creator><![CDATA[C++Greenhorn 0]]></dc:creator><pubDate>Sun, 15 Jun 2008 14:43:26 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Sun, 15 Jun 2008 15:10:33 GMT]]></title><description><![CDATA[<p>Nein, ich bekomme das Bitmap so:</p>
<pre><code class="language-cpp">ExtractIconEx((LPCTSTR)&quot;c:\\file.bmp&quot;, 0, &amp;hIconLarge, NULL, 1);
	GetIconInfo(hIconLarge, &amp;IconInfo);  
	GetObject ( IconInfo.hbmColor, sizeof(BITMAP), &amp;bmp ) ;
</code></pre>
<p>Mit der Typumwandlung habe ich es versucht, da kommt der gleiche Fehler...</p>
<p>Gruß<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1529546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1529546</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Sun, 15 Jun 2008 15:10:33 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Sun, 15 Jun 2008 17:04:31 GMT]]></title><description><![CDATA[<p>BITMAP != HBITMAP</p>
<p>BITMAP und HGDIOBJ sind nicht kompatibel.<br />
HBITMAP und HGDIOBJ schon.</p>
<p>Du willst keine BITMAP sondern ein HBITMAP.</p>
<p>ExtractIconEx() liefert HICON zurück (welches von GetObject() übrigens gar nicht unterstützt wird)</p>
<p>Um ein HICON in eine HBITMAP umzuwandeln:<br />
- Einen MemoryDC erzeugen (CreateCompatibleDC)<br />
- Eine Bitmap der Größe des Icons erzeugen (CreateCompatibleBitmap)<br />
- Bitmap in den MemoryDC selektieren (SelectObject, dessen Rückgabewert speichern!)<br />
- Das Icon auf das MemoryDC und somit in die Bitmap zeichnen (DrawIcon)<br />
- SelectObject() und den gespeicherten Rückgabewert als HGDIOBJ einsetzen<br />
- Die HBITMAP von CreateCompatibleBitmap enthält jetzt dein Icon.<br />
- Sofern das HICON sonst nicht mehr gebraucht wird: DestroyIcon</p>
<p>Die Größe von Small und Large Icons kannst du über GetSystemMetrics() mit SM_CXSMICON, SM_CYSMICON (für Small-Icons) und SM_CXICON, SM_CYICON für Large Icons bestimmen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1529608</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1529608</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Sun, 15 Jun 2008 17:04:31 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Sun, 15 Jun 2008 19:41:16 GMT]]></title><description><![CDATA[<p>Danke,</p>
<p>ich habe es versucht umzustezen:</p>
<pre><code class="language-cpp">HDC hDC = GetDC( NULL ) ;

//- Einen MemoryDC erzeugen (CreateCompatibleDC)
HDC bmpDC = CreateCompatibleDC(hDC);
HDC bmpDC2 = CreateCompatibleDC(hDC);
//- Eine Bitmap der Größe des Icons erzeugen (CreateCompatibleBitmap)
HBITMAP memBM = CreateCompatibleBitmap ( hDC, 32, 32 );
//- Bitmap in den MemoryDC selektieren (SelectObject, dessen Rückgabewert speichern!)
HGDIOBJ myObct = SelectObject(bmpDC, memBM);
//- Das Icon auf das MemoryDC und somit in die Bitmap zeichnen (DrawIcon)
DrawIcon(bmpDC, 0, 0, hIconLarge);
//- SelectObject() und den gespeicherten Rückgabewert als HGDIOBJ einsetzen
myObct = SelectObject(bmpDC2, bmpDC);
//- Die HBITMAP von CreateCompatibleBitmap enthält jetzt dein Icon.
//- Sofern das HICON sonst nicht mehr gebraucht wird: DestroyIcon 

	cout &lt;&lt; &quot;Pixel: &quot; &lt;&lt; GetPixel(bmpDC2, 0, 1) &lt;&lt; &quot;\n&quot;;
	cout &lt;&lt; &quot;Pixel: &quot; &lt;&lt; GetPixel(bmpDC2, 1, 2) &lt;&lt; &quot;\n&quot;;
</code></pre>
<p>Allerdings scheint es nicht zu klappen:<br />
Ausgabe:</p>
<pre><code>Pixel: 4294967295
Pixel: 4294967295
</code></pre>
<p>Habe ich was falsch gemacht?</p>
<p>Gruß<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1529694</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1529694</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Sun, 15 Jun 2008 19:41:16 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Sun, 15 Jun 2008 19:48:20 GMT]]></title><description><![CDATA[<p>Nein an der stelle im bild sind genau 2 weiße pixel -&gt; 0xffffffff.<br />
Das problem ist nur die ausgabe über cout. Das bild selber ist aber richtig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1529699</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1529699</guid><dc:creator><![CDATA[wurst]]></dc:creator><pubDate>Sun, 15 Jun 2008 19:48:20 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Sun, 15 Jun 2008 19:55:40 GMT]]></title><description><![CDATA[<p>Hmm ich bin mir nicht sicher,</p>
<p>ich habe eine kleine Schleife gebaut:</p>
<pre><code class="language-cpp">for(int i=0; i&lt;32; i++){
		for(int i2=0; i2&lt;32; i2++)
			cout &lt;&lt; &quot;Pixel NR &quot; &lt;&lt; i &lt;&lt; &quot;Wert: &quot; &lt;&lt; GetPixel(bmpDC2, i2, i) &lt;&lt; &quot;\n&quot;;
}
</code></pre>
<p>Es kommt immer nur 4294967295 als Wert raus, da stimmt noch nicht alles...</p>
<p>Gruß<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1529706</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1529706</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Sun, 15 Jun 2008 19:55:40 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Sun, 15 Jun 2008 20:36:21 GMT]]></title><description><![CDATA[<p>Ist Dir bewusst, das Dein Code haufenweise GDI-Leaks erzeugt?</p>
<p>Gib die Farben mal Komponentenweise aus (R,G,B) via GetRColor, GetGColor, ... .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1529735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1529735</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sun, 15 Jun 2008 20:36:21 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Sun, 15 Jun 2008 20:47:03 GMT]]></title><description><![CDATA[<p>CodeFinder schrieb:</p>
<blockquote>
<p>Ist Dir bewusst, das Dein Code haufenweise GDI-Leaks erzeugt?</p>
<p>Gib die Farben mal Komponentenweise aus (R,G,B) via GetRColor, GetGColor, ... .</p>
</blockquote>
<p>Hm?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1529751</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1529751</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Sun, 15 Jun 2008 20:47:03 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Sun, 15 Jun 2008 21:40:27 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">HDC hDC = GetDC( NULL ) ;

//- Einen MemoryDC erzeugen (CreateCompatibleDC)
HDC bmpDC = CreateCompatibleDC(hDC);

//- Eine Bitmap der Größe des Icons erzeugen (CreateCompatibleBitmap)
HBITMAP myBMP = CreateCompatibleBitmap ( bmpDC, 32, 32 );

//- Bitmap in den MemoryDC selektieren (SelectObject, dessen Rückgabewert speichern!)
HGDIOBJ fallback;
fallback = SelectObject(bmpDC, myBMP);

//- Das Icon auf das MemoryDC und somit in die Bitmap zeichnen (DrawIcon)
DrawIcon(bmpDC, 1, 1, hIconLarge);

//- SelectObject() und den gespeicherten Rückgabewert als HGDIOBJ einsetzen
SelectObject(bmpDC, myBMP);

//- Die HBITMAP von CreateCompatibleBitmap enthält jetzt dein Icon.
//- Sofern das HICON sonst nicht mehr gebraucht wird: DestroyIcon

	for(int i=0; i&lt;32; i++){
		for(int i2=0; i2&lt;32; i2++)
			cout &lt;&lt; &quot;Pixel NR &quot; &lt;&lt; i &lt;&lt; &quot;Wert: &quot; &lt;&lt; GetPixel(bmpDC, i2, i) &lt;&lt; &quot;\n&quot;;
	}

}
</code></pre>
<p>So scheint es zu funktionieren, was mich aber wundert, ist dass immer wieder nur die gleiche Farbe vorzukommen scheint:</p>
<blockquote>
<p>Pixel NR 7Wert: 16777215<br />
Pixel NR 7Wert: 0<br />
Pixel NR 7Wert: 16777215<br />
Pixel NR 7Wert: 0<br />
Pixel NR 7Wert: 16777215<br />
Pixel NR 7Wert: 0<br />
Pixel NR 7Wert: 16777215<br />
Pixel NR 7Wert: 0<br />
Pixel NR 7Wert: 0<br />
Pixel NR 7Wert: 0<br />
Pixel NR 7Wert: 0<br />
Pixel NR 7Wert: 0<br />
Pixel NR 7Wert: 0<br />
Pixel NR 7Wert: 0<br />
Pixel NR 7Wert: 0<br />
Pixel NR 7Wert: 0<br />
Pixel NR 7Wert: 0<br />
Pixel NR 7Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 16777215<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 0<br />
Pixel NR 8Wert: 16777215</p>
</blockquote>
<p>...usw.<br />
Warum ist es so? Wähle ich ein anderes Icon aus, dann kommt auch jeweils nur dieser Wert oben vor.</p>
<p>16777215 ist ja der RGB Wert für weiß...</p>
<p>EDIT:<br />
Ich habe mal Probehalber folgendes gemacht:</p>
<pre><code class="language-cpp">for(int i=0; i&lt;32; i++){
		for(int i2=0; i2&lt;=32; i2++)
		{
			if(GetPixel(bmpDC, i2, i)==16777215)
				cout &lt;&lt; &quot;X&quot;;
			else
				cout &lt;&lt; &quot;.&quot;;
			if(i2==32)
				cout &lt;&lt; &quot;\n&quot;;
		}
	}
</code></pre>
<p>Es wird dann tatsächlich das Icon gezeichnet. Also es scheint &quot;16777215&quot; an den Stellen zu stehen, wo sich nicht weiße Pixel befinden <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Gruß<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1529774</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1529774</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Sun, 15 Jun 2008 21:40:27 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Sun, 15 Jun 2008 21:36:38 GMT]]></title><description><![CDATA[<p>CodeFinder schrieb:</p>
<blockquote>
<p>Ist Dir bewusst, das Dein Code haufenweise GDI-Leaks erzeugt?</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /></p>
<pre><code>[u]Du Verwendet:[/u]            [u]Benötigt allerdings noch...:[/u]
 CreateCompatibleDC       DeleteDC
 CreateCompatibleBitmap   DeleteObject
 SelectObject             SelectObject ('reselect', siehe MSDN)
</code></pre>
<p>CodeFinder schrieb:</p>
<blockquote>
<p>Gib die Farben mal Komponentenweise aus (R,G,B) via GetRColor, GetGColor, ... .</p>
</blockquote>
<p>Oh sorry, es war nicht GetRColor, sondern GetRValue etc. ...; also something like this:</p>
<pre><code class="language-cpp">cout &lt;&lt; &quot;RGB(&quot; &lt;&lt; GetRValue(color) &lt;&lt; &quot;,&quot; &lt;&lt; GetGValue(color) &lt;&lt; &quot;,&quot; &lt;&lt; GetBValue(color) &lt;&lt; &quot;)&quot; &lt;&lt; endl;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1529777</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1529777</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sun, 15 Jun 2008 21:36:38 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Sun, 15 Jun 2008 21:54:02 GMT]]></title><description><![CDATA[<p>Oh, Du hast natürlich Recht. Vielen Dank. Habe noch keine Erfahrung.</p>
<p>Zu meinem letzten Posting:<br />
Ich glaube ich weiß, wieso das Bitmap monochrom ist:</p>
<blockquote>
<p>Note: When a memory device context is created, it initially has a 1-by-1 monochrome bitmap selected into it. If this memory device context is used in CreateCompatibleBitmap, the bitmap that is created is a monochrome bitmap. To create a color bitmap, use the hDC that was used to create the memory device context, as shown in the following code:</p>
<p>HDC memDC = CreateCompatibleDC ( hDC );<br />
HBITMAP memBM = CreateCompatibleBitmap ( hDC, nWidth, nHeight );<br />
SelectObject ( memDC, memBM );</p>
</blockquote>
<p>Das Problem ist wahrscheinlich hier:</p>
<pre><code class="language-cpp">HDC hDC = GetDC( NULL ) ;
//- Einen MemoryDC erzeugen (CreateCompatibleDC)
HDC bmpDC = CreateCompatibleDC(hDC);
//- Eine Bitmap der Größe des Icons erzeugen (CreateCompatibleBitmap)
HBITMAP myBMP = CreateCompatibleBitmap ( bmpDC, 32, 32 );
</code></pre>
<p>Aber meine Anwendung hat kein hDC, weil es als Win32 Consolenanwendung erstellt wurde (ich hoffe ich bringe jetzt nicht komplett alles durcheinander...)</p>
<p>Gruß<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1529789</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1529789</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Sun, 15 Jun 2008 21:54:02 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Sun, 15 Jun 2008 22:49:31 GMT]]></title><description><![CDATA[<p>Öhm, ne bringst nix durcheinander (sogar lobenswert, dass hier entlich mal einer in die MSDN guckt <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="😉"
    /> !), aber daran liegts trotzdem nicht, denn:</p>
<p>MSDN zu GetDC schrieb:</p>
<blockquote>
<p>Handle to the window whose DC is to be retrieved. <strong>If this value is NULL, GetDC retrieves the DC for the entire screen.</strong></p>
</blockquote>
<p>(Bezogen auf den Parameter; Quelle: <a href="http://msdn.microsoft.com/en-us/library/ms533241.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms533241.aspx</a>)<br />
Sie ist also nicht mono.</p>
<p>Ich schau mir -falls es nicht jemand anderes bis dahin schon getan hat- Deinen Code Morgen Abend mal an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1529818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1529818</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sun, 15 Jun 2008 22:49:31 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Mon, 16 Jun 2008 05:42:18 GMT]]></title><description><![CDATA[<p>Vielen Dank.</p>
<p>Hier der ganze Codeabschnitt, damit es einfacher mit dem Angucken ist:</p>
<pre><code class="language-cpp">//ICON auslesen
	ExtractIconEx((LPCTSTR)&quot;c:\\CtrlSrv.exe&quot;, 0, &amp;hIconLarge, NULL, 1);
	GetIconInfo(hIconLarge, &amp;IconInfo);  

HDC hDC = GetDC( NULL ) ;

//- Einen MemoryDC erzeugen (CreateCompatibleDC)
HDC bmpDC = CreateCompatibleDC(hDC);

//- Eine Bitmap der Größe des Icons erzeugen (CreateCompatibleBitmap)
HBITMAP myBMP = CreateCompatibleBitmap ( bmpDC, 32, 32 );

//- Bitmap in den MemoryDC selektieren (SelectObject, dessen Rückgabewert speichern!)
HGDIOBJ fallback;
fallback = SelectObject(bmpDC, myBMP);

//- Das Icon auf das MemoryDC und somit in die Bitmap zeichnen (DrawIcon)
DrawIcon(bmpDC, 0, 0, hIconLarge);

//- SelectObject() und den gespeicherten Rückgabewert als HGDIOBJ einsetzen
SelectObject(bmpDC, myBMP);

	for(int i=0; i&lt;32; i++){
		for(int i2=0; i2&lt;=32; i2++)
		{
			//cout &lt;&lt; &quot;Pixel NR &quot; &lt;&lt; i &lt;&lt; &quot;Wert: &quot; &lt;&lt; GetPixel(bmpDC, i2, i) &lt;&lt; &quot;\n&quot;;
			if(GetPixel(bmpDC, i2, i)==16777215)
				cout &lt;&lt; &quot;X&quot;;
			else
				cout &lt;&lt; &quot;.&quot;;
			if(i2==32)
				cout &lt;&lt; &quot;\n&quot;;
		}
	}

	DeleteDC(hDC);
	DeleteDC(bmpDC);
	DeleteObject(myBMP); 
	DeleteObject(fallback); 
	DestroyIcon(hIconLarge);
</code></pre>
<p>Grüße<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1529862</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1529862</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Mon, 16 Jun 2008 05:42:18 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Mon, 16 Jun 2008 12:17:25 GMT]]></title><description><![CDATA[<p>Jo gib bei CreateCompatibleDC() nicht bmpDC (welches monochrom ist anfangs) sondern hDC an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1530061</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1530061</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Mon, 16 Jun 2008 12:17:25 GMT</pubDate></item><item><title><![CDATA[Reply to BITMAP&#x27; in &#x27;HGDIOBJ&#x27; nicht möglich on Mon, 16 Jun 2008 12:44:11 GMT]]></title><description><![CDATA[<p>geeky schrieb:</p>
<blockquote>
<p>Jo gib bei CreateCompatibleDC() nicht bmpDC (welches monochrom ist anfangs) sondern hDC an.</p>
</blockquote>
<p>Danke, jetzt klappt es!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1530090</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1530090</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Mon, 16 Jun 2008 12:44:11 GMT</pubDate></item></channel></rss>