<?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[GID: HBITMAP und HDC ?]]></title><description><![CDATA[<p>Hi...wollte mal fragen wie ich ein bitmap in ein hdc konvertiere und andersrum ?</p>
<p>und wieso bekomme ich hier<br />
0,0<br />
0,0 ?</p>
<pre><code class="language-cpp">POINT findImageOnScreen(HBITMAP img, HDC screen)
{
	HDC hdcCompatible = CreateCompatibleDC(screen); 
	HBITMAP screenBitmap = CreateCompatibleBitmap(screen, GetDeviceCaps(screen, VERTRES), GetDeviceCaps(screen, HORZRES));
	SelectObject(hdcCompatible, screenBitmap);
	BitBlt(hdcCompatible,0,0,GetDeviceCaps(screen, VERTRES), GetDeviceCaps(screen, HORZRES), screen, 0,0,SRCCOPY) ;

	SIZE bitmapSize;
	GetBitmapDimensionEx(img, &amp;bitmapSize);
	SIZE screenSize;
	GetBitmapDimensionEx(screenBitmap, &amp;screenSize);
	printf(&quot;ScreenSize: %i, %i \n&quot;, screenSize.cx, screenSize.cy);
	printf(&quot;bitmapSize: %i, %i \n&quot;, bitmapSize.cx, bitmapSize.cy);
// [...]
</code></pre>
<p>?? die bitmap(img) ist vorhanden und wird geladen</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/182062/gid-hbitmap-und-hdc</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Jul 2026 15:52:39 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/182062.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 21 May 2007 04:51:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GID: HBITMAP und HDC ? on Mon, 21 May 2007 04:51:56 GMT]]></title><description><![CDATA[<p>Hi...wollte mal fragen wie ich ein bitmap in ein hdc konvertiere und andersrum ?</p>
<p>und wieso bekomme ich hier<br />
0,0<br />
0,0 ?</p>
<pre><code class="language-cpp">POINT findImageOnScreen(HBITMAP img, HDC screen)
{
	HDC hdcCompatible = CreateCompatibleDC(screen); 
	HBITMAP screenBitmap = CreateCompatibleBitmap(screen, GetDeviceCaps(screen, VERTRES), GetDeviceCaps(screen, HORZRES));
	SelectObject(hdcCompatible, screenBitmap);
	BitBlt(hdcCompatible,0,0,GetDeviceCaps(screen, VERTRES), GetDeviceCaps(screen, HORZRES), screen, 0,0,SRCCOPY) ;

	SIZE bitmapSize;
	GetBitmapDimensionEx(img, &amp;bitmapSize);
	SIZE screenSize;
	GetBitmapDimensionEx(screenBitmap, &amp;screenSize);
	printf(&quot;ScreenSize: %i, %i \n&quot;, screenSize.cx, screenSize.cy);
	printf(&quot;bitmapSize: %i, %i \n&quot;, bitmapSize.cx, bitmapSize.cy);
// [...]
</code></pre>
<p>?? die bitmap(img) ist vorhanden und wird geladen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1288797</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1288797</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Mon, 21 May 2007 04:51:56 GMT</pubDate></item><item><title><![CDATA[Reply to GID: HBITMAP und HDC ? on Mon, 21 May 2007 07:07:38 GMT]]></title><description><![CDATA[<p>HBITMAP und HDC sind zwei unterschiedliche Dinge, die kann man nich ineinander konvertieren.<br />
Ein DeviceContext ist im übertragenen Sinne ne Art Zeichenbrett, worauf du dein Papier (HBITMAP) legen kannst. Mittels SelectObject() kannst du deine Pinsel etc. auswählen. BitBlt() kopiert Inhalt des Papiers auf das Papier eines anderen Zeichenbretts.</p>
<blockquote>
<p>The GetBitmapDimensionEx function retrieves the dimensions of a compatible bitmap. The retrieved dimensions <strong>must have been set by the SetBitmapDimensionEx function.</strong></p>
</blockquote>
<p>Schau dir mal stattdessen GetObject() an!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1288830</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1288830</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Mon, 21 May 2007 07:07:38 GMT</pubDate></item><item><title><![CDATA[Reply to GID: HBITMAP und HDC ? on Mon, 21 May 2007 14:02:49 GMT]]></title><description><![CDATA[<p>So jetzt hab ich aber was ganz seltsames oO</p>
<pre><code class="language-cpp">POINT findImageOnScreen(HBITMAP img, HDC screen)
{
	HDC hdcCompatible = CreateCompatibleDC(screen); 
	HBITMAP screenBitmap = CreateCompatibleBitmap(screen, GetDeviceCaps(screen, VERTRES), GetDeviceCaps(screen, HORZRES));
	SelectObject(hdcCompatible, screenBitmap);
	BitBlt(hdcCompatible,0,0,GetDeviceCaps(screen, VERTRES), GetDeviceCaps(screen, HORZRES), screen, 0,0,SRCCOPY) ;
	HDC hdcImage = CreateCompatibleDC(screen);
	SelectObject(hdcImage,img);
	BITMAP imgInfo;
	GetObject(img, sizeof(BITMAP), (LPSTR)&amp;imgInfo);
	BITMAP screenInfo;
	GetObject(screenBitmap, sizeof(BITMAP), (LPSTR)&amp;screenInfo);
	SIZE bitmapSize;

	bitmapSize.cx = imgInfo.bmWidth;
	bitmapSize.cy = imgInfo.bmHeight;
	SIZE screenSize;
	screenSize.cx = screenInfo.bmWidth;
	screenSize.cy = screenInfo.bmHeight;
	printf(&quot;ScreenSize: %i | %i \n&quot;, screenSize.cx, screenSize.cy);
	printf(&quot;bitmapSize: %i, %i \n&quot;, bitmapSize.cx, bitmapSize.cy);
	for(int i = 0; i &lt; screenSize.cx; i++)
		for(int j = 0; j &lt; screenSize.cy; j++)
		{
			if(cc(GetPixel(hdcImage,0,0), GetPixel(screen, i, j)))
			{
				//printf(&quot;Fitting entry pixel found @ %i, %i \n&quot;, i, j);
				bool found = true;
				for(int k = 0; (k &lt; bitmapSize.cx) &amp; (found == true); k++)
					for(int l = 0; (l &lt; bitmapSize.cy) &amp; (found == true); l++)
						if(!cc(GetPixel(hdcImage,k,l), GetPixel(screen, i+k, j+l)))
							found = false;
				if(found == true)
				{
					POINT ret;
					ret.x = i;
					ret.y = j;
					return ret;
				}
			}
		}
	POINT ret;
	ret.x = -1;
	ret.y = -1;
	return ret;
}

int main(int argc, char* argv[])
{
	HDC hdcScreen = GetDC(0);
	HBITMAP img = loadImg(&quot;test.bmp&quot;);
	if(!img)
		printf(&quot;Image not found \n&quot;);
	else
	{
		POINT test = findImageOnScreen(img,hdcScreen);
		printf(&quot;found @ %i, %i \n&quot;, test.x, test.y);
	}
	return 0;
}
</code></pre>
<p>interessant wirds bei<br />
printf(&quot;ScreenSize: %i | %i \n&quot;, <a href="http://screenSize.cx" rel="nofollow">screenSize.cx</a>, <a href="http://screenSize.cy" rel="nofollow">screenSize.cy</a>);<br />
denn hier bekomme ich 1024 | 1280 ausgegeben !!<br />
wieso wird da breite und höhe ausgetauscht ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1289098</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1289098</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Mon, 21 May 2007 14:02:49 GMT</pubDate></item><item><title><![CDATA[Reply to GID: HBITMAP und HDC ? on Mon, 21 May 2007 14:25:24 GMT]]></title><description><![CDATA[<p>Weil du sie bei CreateCompatibleBitmap(screen, GetDeviceCaps(screen, VERTRES), GetDeviceCaps(screen, HORZRES)); schon falsch herum angegeben hast <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1289142</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1289142</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Mon, 21 May 2007 14:25:24 GMT</pubDate></item></channel></rss>