<?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[Screenshot - sofort verarbeiten, nicht in Datei schreiben]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>folgendes Problem: ich möchte gern einen Screenshot von einem Ausschnitt eines Fensters machen. Dies klappt auch - allerdings nur, wenn ich &quot;das Ergebnis in eine Datei schreibe&quot;. Dass heißt im unten folgenden Quelltext werden die Daten nur richtig in das Array geschrieben, wenn das <strong>mittlere Codesegment</strong> vorher ausgeführt wird. Lasse ich ihn weg, so steht im Array immer ein und dieselbe Zahl. Daraus schließe ich, dass ich irgendeinen der Befehle benötige, anscheinend das</p>
<pre><code class="language-cpp">aBmp=CreateDIBSection(SourceDC,&amp;bi,DIB_RGB_COLORS,(void**)&amp;dibvalues,NULL,NULL);
</code></pre>
<p>damit der Code richtig arbeitet. Nun bezieht sich diese Funktion aber auf den BitmapInfoHeader etc. und den brauche ich nicht.</p>
<p><strong>Meine konkrete Frage:</strong> Welchen Code muss ich statt des <strong>mittleren Codesegmentes</strong> einfügen, dass das Array richtig gefüllt wird?</p>
<p>Viele Grüße<br />
Richard</p>
<pre><code class="language-cpp">char* Client::GetPixelField(void)
{
	HDC SourceDC = GetWindowDC(this-&gt;hMessageWin);			/* create a device context for the message window */
	HDC DestDC = CreateCompatibleDC(SourceDC);

	RECT rect;										/* resolution of the message window */
	GetWindowRect(this-&gt;hMessageWin, &amp;rect);		/* get window size */
	int width = rect.right-rect.left;				/* calculate width */
	int height = rect.bottom-rect.top;				/* calculate height */

	unsigned long detected_color[86][209];			/* to save the last line of the message win */
</code></pre>
<pre><code class="language-cpp">HBITMAP aBmp;
    BITMAPINFO bi;
    HGDIOBJ OldObj;
    void *dibvalues;
    HANDLE fileHandle;

    BITMAPFILEHEADER bmfh;
    BITMAPINFOHEADER bmih;
    DWORD bytes_write;
    DWORD bytes_written;

    ZeroMemory(&amp;bmih,sizeof(BITMAPINFOHEADER));
    bmih.biSize=sizeof(BITMAPINFOHEADER);
    bmih.biHeight=height-0;
    bmih.biWidth=width-0;
    bmih.biPlanes=1;
    bmih.biBitCount=24; //24
    bmih.biCompression=BI_RGB;
    bmih.biSizeImage = ((((bmih.biWidth * bmih.biBitCount) + 31) &amp; ~31) &gt;&gt; 3) * bmih.biHeight;
    bmih.biXPelsPerMeter = 0;
    bmih.biYPelsPerMeter = 0;
    bmih.biClrImportant = 0;

    bi.bmiHeader=bmih;

    aBmp=CreateDIBSection(SourceDC,&amp;bi,DIB_RGB_COLORS,(void**)&amp;dibvalues,NULL,NULL);

    if (aBmp==NULL)
    {
        OutputDebugString(&quot;CreateDIBSection failed!\n&quot;);
        return 0;
    }

	OldObj=SelectObject(DestDC,aBmp);
</code></pre>
<pre><code class="language-cpp">BitBlt(DestDC,0,0,width,height,SourceDC,0,0,SRCCOPY);

     //Pixel auslesen
	for(int y_counter=0;y_counter &lt; height; y_counter++)
		for(int x_counter=0; x_counter &lt; width; x_counter++)
			detected_color[y_counter][x_counter] = GetPixel(DestDC, x_counter,y_counter);

	return NULL;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/187253/screenshot-sofort-verarbeiten-nicht-in-datei-schreiben</link><generator>RSS for Node</generator><lastBuildDate>Sat, 04 Jul 2026 11:17:21 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/187253.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 17 Jul 2007 16:28:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Screenshot - sofort verarbeiten, nicht in Datei schreiben on Tue, 17 Jul 2007 16:28:50 GMT]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>folgendes Problem: ich möchte gern einen Screenshot von einem Ausschnitt eines Fensters machen. Dies klappt auch - allerdings nur, wenn ich &quot;das Ergebnis in eine Datei schreibe&quot;. Dass heißt im unten folgenden Quelltext werden die Daten nur richtig in das Array geschrieben, wenn das <strong>mittlere Codesegment</strong> vorher ausgeführt wird. Lasse ich ihn weg, so steht im Array immer ein und dieselbe Zahl. Daraus schließe ich, dass ich irgendeinen der Befehle benötige, anscheinend das</p>
<pre><code class="language-cpp">aBmp=CreateDIBSection(SourceDC,&amp;bi,DIB_RGB_COLORS,(void**)&amp;dibvalues,NULL,NULL);
</code></pre>
<p>damit der Code richtig arbeitet. Nun bezieht sich diese Funktion aber auf den BitmapInfoHeader etc. und den brauche ich nicht.</p>
<p><strong>Meine konkrete Frage:</strong> Welchen Code muss ich statt des <strong>mittleren Codesegmentes</strong> einfügen, dass das Array richtig gefüllt wird?</p>
<p>Viele Grüße<br />
Richard</p>
<pre><code class="language-cpp">char* Client::GetPixelField(void)
{
	HDC SourceDC = GetWindowDC(this-&gt;hMessageWin);			/* create a device context for the message window */
	HDC DestDC = CreateCompatibleDC(SourceDC);

	RECT rect;										/* resolution of the message window */
	GetWindowRect(this-&gt;hMessageWin, &amp;rect);		/* get window size */
	int width = rect.right-rect.left;				/* calculate width */
	int height = rect.bottom-rect.top;				/* calculate height */

	unsigned long detected_color[86][209];			/* to save the last line of the message win */
</code></pre>
<pre><code class="language-cpp">HBITMAP aBmp;
    BITMAPINFO bi;
    HGDIOBJ OldObj;
    void *dibvalues;
    HANDLE fileHandle;

    BITMAPFILEHEADER bmfh;
    BITMAPINFOHEADER bmih;
    DWORD bytes_write;
    DWORD bytes_written;

    ZeroMemory(&amp;bmih,sizeof(BITMAPINFOHEADER));
    bmih.biSize=sizeof(BITMAPINFOHEADER);
    bmih.biHeight=height-0;
    bmih.biWidth=width-0;
    bmih.biPlanes=1;
    bmih.biBitCount=24; //24
    bmih.biCompression=BI_RGB;
    bmih.biSizeImage = ((((bmih.biWidth * bmih.biBitCount) + 31) &amp; ~31) &gt;&gt; 3) * bmih.biHeight;
    bmih.biXPelsPerMeter = 0;
    bmih.biYPelsPerMeter = 0;
    bmih.biClrImportant = 0;

    bi.bmiHeader=bmih;

    aBmp=CreateDIBSection(SourceDC,&amp;bi,DIB_RGB_COLORS,(void**)&amp;dibvalues,NULL,NULL);

    if (aBmp==NULL)
    {
        OutputDebugString(&quot;CreateDIBSection failed!\n&quot;);
        return 0;
    }

	OldObj=SelectObject(DestDC,aBmp);
</code></pre>
<pre><code class="language-cpp">BitBlt(DestDC,0,0,width,height,SourceDC,0,0,SRCCOPY);

     //Pixel auslesen
	for(int y_counter=0;y_counter &lt; height; y_counter++)
		for(int x_counter=0; x_counter &lt; width; x_counter++)
			detected_color[y_counter][x_counter] = GetPixel(DestDC, x_counter,y_counter);

	return NULL;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1327353</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1327353</guid><dc:creator><![CDATA[Richard]]></dc:creator><pubDate>Tue, 17 Jul 2007 16:28:50 GMT</pubDate></item><item><title><![CDATA[Reply to Screenshot - sofort verarbeiten, nicht in Datei schreiben on Wed, 18 Jul 2007 11:20:11 GMT]]></title><description><![CDATA[<p>Ich habe das Problem selbst lösen können. Für alle Interessierten hier der Quellcode:</p>
<pre><code class="language-cpp">HDC SourceDC = GetWindowDC(this-&gt;hMessageWin);			/* create a device context for the message window */
	HDC DestDC = CreateCompatibleDC(SourceDC);

	HBITMAP hBitmap;										/* handle to the bitmap */

	RECT rect;										/* resolution of the message window */
	GetWindowRect(this-&gt;hMessageWin, &amp;rect);		/* get window size */
	int width = rect.right-rect.left;				/* calculate width */
	int height = rect.bottom-rect.top;				/* calculate height */

	unsigned long detected_color[86][209];			/* to save the last line of the message win */

	hBitmap = CreateCompatibleBitmap (SourceDC, width, height);		/* create a bitmap compatible with the device associated with the device context */

	SelectObject(DestDC, hBitmap);
	BitBlt(DestDC,0,0,width,height,SourceDC,0,0,SRCCOPY);

     //Pixel auslesen
	for(int y_counter=0;y_counter &lt; height; y_counter++)
		for(int x_counter=0; x_counter &lt; width; x_counter++)
			detected_color[y_counter][x_counter] = GetPixel(DestDC, x_counter,y_counter);

	DeleteObject(hBitmap);				// delete the bitmap object and free all resources associated with it
  	DeleteDC(SourceDC);					// delete the device contexts
	DeleteDC(DestDC);

	return NULL;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1327707</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1327707</guid><dc:creator><![CDATA[Richard]]></dc:creator><pubDate>Wed, 18 Jul 2007 11:20:11 GMT</pubDate></item><item><title><![CDATA[Reply to Screenshot - sofort verarbeiten, nicht in Datei schreiben on Wed, 18 Jul 2007 14:39:10 GMT]]></title><description><![CDATA[<p>GetPixel() ist allerdings gegenüber dem Pixel-Array der DIB um einiges lahmer <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=";D"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1327852</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1327852</guid><dc:creator><![CDATA[geeky]]></dc:creator><pubDate>Wed, 18 Jul 2007 14:39:10 GMT</pubDate></item></channel></rss>