<?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[frisch kreierte DIBSection beim Blit schwarz..]]></title><description><![CDATA[<p>Also ich hab ne DIBSection kreiert in die ich ein Bild legen will. Anschließend soll das Ganze geblittet werden.<br />
Nur bleibt bei mir der Screen schwarz:</p>
<pre><code class="language-cpp">void blit (cImage *img, HDC hDC, int x, int y) {
	BITMAPINFO bmi;
	HBITMAP DIBSec;

	ZeroMemory (&amp;bmi, sizeof(bmi));
	/* Create Bitmap Header */
	bmi.bmiHeader.biSize		= sizeof(BITMAPINFOHEADER);
	bmi.bmiHeader.biWidth 		= img-&gt;getWidth();
	bmi.bmiHeader.biHeight 		= img-&gt;getHeight();
	bmi.bmiHeader.biBitCount 	= img-&gt;getBPP() * 8;
	bmi.bmiHeader.biPlanes 		= 1;
	bmi.bmiHeader.biCompression = BI_RGB;
	bmi.bmiHeader.biSizeImage 	= img-&gt;getBPP() * img-&gt;getWidth() * img-&gt;getHeight();

	/* Create Bitmap */
	unsigned char *lpdata = new unsigned char[bmi.bmiHeader.biSizeImage];
    DIBSec = CreateDIBSection( NULL, &amp;bmi, DIB_RGB_COLORS, (void**)lpdata, NULL, 0);
    CopyMemory ((void*)lpdata, (const void*)img-&gt;getImage(), bmi.bmiHeader.biSizeImage);

//	DIBSec = LoadBitmap (thisInstance, &quot;grfx/test.bmp&quot;);
	/* Blit Image */
    HDC     iDC = CreateCompatibleDC(hDC);
    SelectObject(iDC, DIBSec);
    BitBlt(hDC, x, y, img-&gt;getWidth(), img-&gt;getHeight(), iDC, 0, 0, SRCCOPY );

	/* Cleanup */
    DeleteDC(iDC);
    DeleteObject (DIBSec);
    delete lpdata;
}
</code></pre>
<p>Hatte, wie man sieht, auch mal versucht, nen bitmap reinzuladen und das darzustellen.. da war dann nichtmal das schwarze Bild zu erkennen..</p>
<p>mein Windows loop sieht so aus</p>
<pre><code class="language-cpp">try {    
    cam = new cCam (hwnd);
    HDC hDC = GetDC(hwnd);

	    /* Make the window visible on the screen */
	    ShowWindow (hwnd, nFunsterStil);
	    int done = 0;
	    img = cam-&gt;getImage();

	    load = loadBMPImage(&quot;grfx/test.bmp&quot;); 

	    /* Run the message loop. It will run until GetMessage() returns 0 */
	    while (!done) {
	        if (PeekMessage (&amp;messages, NULL, 0, 0, PM_REMOVE)) {
	            if (messages.message == WM_QUIT) {
	                done = 1;
	            } else {
	                /* Translate virtual-key messages into character messages */
	                TranslateMessage(&amp;messages);
	                /* Send message to WindowProcedure */
	                DispatchMessage(&amp;messages);
	            }
	        } else {
	            blit(load, hDC, 320, 0);
	            img = cam-&gt;getImage();
	        }
	    }
	    ReleaseDC(hwnd, hDC);
	} catch (char *e){
		MessageBox (NULL, e, &quot;Fehler&quot;, MB_OK);
		PostQuitMessage(0);
	}
</code></pre>
<p>weiß zufällig wer, was ich korrigieren muss?</p>
<p>cYa &amp; thx<br />
DjR</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/184766/frisch-kreierte-dibsection-beim-blit-schwarz</link><generator>RSS for Node</generator><lastBuildDate>Mon, 06 Jul 2026 00:28:13 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/184766.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 19 Jun 2007 04:23:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to frisch kreierte DIBSection beim Blit schwarz.. on Tue, 19 Jun 2007 04:23:29 GMT]]></title><description><![CDATA[<p>Also ich hab ne DIBSection kreiert in die ich ein Bild legen will. Anschließend soll das Ganze geblittet werden.<br />
Nur bleibt bei mir der Screen schwarz:</p>
<pre><code class="language-cpp">void blit (cImage *img, HDC hDC, int x, int y) {
	BITMAPINFO bmi;
	HBITMAP DIBSec;

	ZeroMemory (&amp;bmi, sizeof(bmi));
	/* Create Bitmap Header */
	bmi.bmiHeader.biSize		= sizeof(BITMAPINFOHEADER);
	bmi.bmiHeader.biWidth 		= img-&gt;getWidth();
	bmi.bmiHeader.biHeight 		= img-&gt;getHeight();
	bmi.bmiHeader.biBitCount 	= img-&gt;getBPP() * 8;
	bmi.bmiHeader.biPlanes 		= 1;
	bmi.bmiHeader.biCompression = BI_RGB;
	bmi.bmiHeader.biSizeImage 	= img-&gt;getBPP() * img-&gt;getWidth() * img-&gt;getHeight();

	/* Create Bitmap */
	unsigned char *lpdata = new unsigned char[bmi.bmiHeader.biSizeImage];
    DIBSec = CreateDIBSection( NULL, &amp;bmi, DIB_RGB_COLORS, (void**)lpdata, NULL, 0);
    CopyMemory ((void*)lpdata, (const void*)img-&gt;getImage(), bmi.bmiHeader.biSizeImage);

//	DIBSec = LoadBitmap (thisInstance, &quot;grfx/test.bmp&quot;);
	/* Blit Image */
    HDC     iDC = CreateCompatibleDC(hDC);
    SelectObject(iDC, DIBSec);
    BitBlt(hDC, x, y, img-&gt;getWidth(), img-&gt;getHeight(), iDC, 0, 0, SRCCOPY );

	/* Cleanup */
    DeleteDC(iDC);
    DeleteObject (DIBSec);
    delete lpdata;
}
</code></pre>
<p>Hatte, wie man sieht, auch mal versucht, nen bitmap reinzuladen und das darzustellen.. da war dann nichtmal das schwarze Bild zu erkennen..</p>
<p>mein Windows loop sieht so aus</p>
<pre><code class="language-cpp">try {    
    cam = new cCam (hwnd);
    HDC hDC = GetDC(hwnd);

	    /* Make the window visible on the screen */
	    ShowWindow (hwnd, nFunsterStil);
	    int done = 0;
	    img = cam-&gt;getImage();

	    load = loadBMPImage(&quot;grfx/test.bmp&quot;); 

	    /* Run the message loop. It will run until GetMessage() returns 0 */
	    while (!done) {
	        if (PeekMessage (&amp;messages, NULL, 0, 0, PM_REMOVE)) {
	            if (messages.message == WM_QUIT) {
	                done = 1;
	            } else {
	                /* Translate virtual-key messages into character messages */
	                TranslateMessage(&amp;messages);
	                /* Send message to WindowProcedure */
	                DispatchMessage(&amp;messages);
	            }
	        } else {
	            blit(load, hDC, 320, 0);
	            img = cam-&gt;getImage();
	        }
	    }
	    ReleaseDC(hwnd, hDC);
	} catch (char *e){
		MessageBox (NULL, e, &quot;Fehler&quot;, MB_OK);
		PostQuitMessage(0);
	}
</code></pre>
<p>weiß zufällig wer, was ich korrigieren muss?</p>
<p>cYa &amp; thx<br />
DjR</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1308779</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1308779</guid><dc:creator><![CDATA[DocJunioR]]></dc:creator><pubDate>Tue, 19 Jun 2007 04:23:29 GMT</pubDate></item><item><title><![CDATA[Reply to frisch kreierte DIBSection beim Blit schwarz.. on Wed, 20 Jun 2007 10:04:55 GMT]]></title><description><![CDATA[<p>Also ich bekomm das jetzt so weit hin.</p>
<pre><code class="language-cpp">void blit (cImage *img, HDC hDC, int x, int y) {
	BITMAPINFO bmi;
	HBITMAP DIBSec;

	unsigned char *lpdata = new unsigned char[bmi.bmiHeader.biSizeImage];
	/* Create Bitmap Header */
	ZeroMemory (&amp;bmi.bmiHeader, sizeof(BITMAPINFOHEADER));
	bmi.bmiHeader.biSize		= sizeof(BITMAPINFOHEADER);
	bmi.bmiHeader.biWidth 		= img-&gt;getWidth();
	bmi.bmiHeader.biHeight 		= img-&gt;getHeight();
	bmi.bmiHeader.biPlanes 		= 1;
	bmi.bmiHeader.biBitCount 	= img-&gt;getBPP() * 8;
	bmi.bmiHeader.biSizeImage 	= img-&gt;getBPP() * img-&gt;getWidth() * img-&gt;getHeight();

	/* Create Bitmap */
    DIBSec = CreateDIBSection( 0, &amp;bmi, DIB_RGB_COLORS, (void**)lpdata, 0, 0);
    SetDIBits (0, DIBSec, 0, bmi.bmiHeader.biHeight, img-&gt;getImage(), &amp;bmi, DIB_RGB_COLORS);

	/* Blit Image */
    HDC     iDC = CreateCompatibleDC(hDC);
    SelectObject(iDC, DIBSec);
    BitBlt(hDC, x, y, img-&gt;getWidth(), img-&gt;getHeight(), iDC, 0, 0, SRCCOPY );

	/* Cleanup */
    DeleteObject (DIBSec);
    ReleaseDC(0, iDC);
    delete lpdata;
}
</code></pre>
<p>Das SetDIBits macht scheinbar noch mehr als ein CopyMemory.</p>
<p>Wie dem auch sei, jetzt hab ich doch einen interessanten Effekt.<br />
Ich nehme ein Bild mit einer Webcam auf und stelle es per blit (s.o.) dar.<br />
Das funktioniert super- solange die Maus nicht das Fenster berührt in dem das Ganze stattfindet..<br />
Woran kann sowas liegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1309745</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1309745</guid><dc:creator><![CDATA[DocJunioR]]></dc:creator><pubDate>Wed, 20 Jun 2007 10:04:55 GMT</pubDate></item></channel></rss>