<?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[Dimension eines CBitmap]]></title><description><![CDATA[<p>Ich möchte eine *.bmp Datei von der Festplatte einlesen und auf ein CDC ausgeben.</p>
<p>dazu benutze ich die Funktion</p>
<pre><code class="language-cpp">LoadBMPImage((LPCTSTR)csFileName, DrawMeBmp, NULL );
</code></pre>
<p>aus <a href="http://www.codeguru.com/cpp/g-m/bitmap/article.php/c1681/" rel="nofollow">http://www.codeguru.com/cpp/g-m/bitmap/article.php/c1681/</a></p>
<p>um das Bitmap zu laden. Danach möchte ich dieses Bitmap auf das DC ausgeben, und benötige dazu die Dimensionen. Probiert habe ich es mit</p>
<pre><code class="language-cpp">CRect BitmapRect(0,0,0,0);
	BitmapRect.right = DrawMeBmp.GetBitmapDimension().cx;
	BitmapRect.bottom = DrawMeBmp.GetBitmapDimension().cy;
</code></pre>
<p>was mir aber nur 0 als Wert zurückliefert.</p>
<p>Sind die Aufrufe GetBitmapDimension().cx nicht richtig, oder wird das CBitmap nicht richtig initialisiert?</p>
<p>Die ganze Funktion sieht übrigens wie folgt aus, wobei Sie mir nur ein weißes Bild ohne Inhalt liefert.</p>
<pre><code class="language-cpp">CPaintDC dc(this); 
	CRect (rc);
	GetClientRect(rc);
	CMemDC pDC(&amp;dc,&amp;rc);

	CDC SourceDC;
	SourceDC.CreateCompatibleDC(NULL);

	CBitmap DrawMeBmp;
	CPalette *pPal;

	BOOL Result = BitmapOperations.LoadBMPImage((LPCTSTR)csFileName, DrawMeBmp, NULL );

	CBitmap* pOldBitmap = SourceDC.SelectObject(&amp;DrawMeBmp);

	CRect BitmapRect(0,0,0,0);
	BitmapRect.right = DrawMeBmp.GetBitmapDimension().cx;
	BitmapRect.bottom = DrawMeBmp.GetBitmapDimension().cy;
	pDC-&gt;BitBlt(0,0, BitmapRect.Width(), BitmapRect.Height(), &amp;SourceDC, 0, 0, SRCCOPY );
        //clean up...
	SourceDC.SelectObject(pOldBitmap);
	SourceDC.DeleteDC();
</code></pre>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/180013/dimension-eines-cbitmap</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 11:53:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/180013.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 27 Apr 2007 14:56:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dimension eines CBitmap on Fri, 27 Apr 2007 15:13:54 GMT]]></title><description><![CDATA[<p>Ich möchte eine *.bmp Datei von der Festplatte einlesen und auf ein CDC ausgeben.</p>
<p>dazu benutze ich die Funktion</p>
<pre><code class="language-cpp">LoadBMPImage((LPCTSTR)csFileName, DrawMeBmp, NULL );
</code></pre>
<p>aus <a href="http://www.codeguru.com/cpp/g-m/bitmap/article.php/c1681/" rel="nofollow">http://www.codeguru.com/cpp/g-m/bitmap/article.php/c1681/</a></p>
<p>um das Bitmap zu laden. Danach möchte ich dieses Bitmap auf das DC ausgeben, und benötige dazu die Dimensionen. Probiert habe ich es mit</p>
<pre><code class="language-cpp">CRect BitmapRect(0,0,0,0);
	BitmapRect.right = DrawMeBmp.GetBitmapDimension().cx;
	BitmapRect.bottom = DrawMeBmp.GetBitmapDimension().cy;
</code></pre>
<p>was mir aber nur 0 als Wert zurückliefert.</p>
<p>Sind die Aufrufe GetBitmapDimension().cx nicht richtig, oder wird das CBitmap nicht richtig initialisiert?</p>
<p>Die ganze Funktion sieht übrigens wie folgt aus, wobei Sie mir nur ein weißes Bild ohne Inhalt liefert.</p>
<pre><code class="language-cpp">CPaintDC dc(this); 
	CRect (rc);
	GetClientRect(rc);
	CMemDC pDC(&amp;dc,&amp;rc);

	CDC SourceDC;
	SourceDC.CreateCompatibleDC(NULL);

	CBitmap DrawMeBmp;
	CPalette *pPal;

	BOOL Result = BitmapOperations.LoadBMPImage((LPCTSTR)csFileName, DrawMeBmp, NULL );

	CBitmap* pOldBitmap = SourceDC.SelectObject(&amp;DrawMeBmp);

	CRect BitmapRect(0,0,0,0);
	BitmapRect.right = DrawMeBmp.GetBitmapDimension().cx;
	BitmapRect.bottom = DrawMeBmp.GetBitmapDimension().cy;
	pDC-&gt;BitBlt(0,0, BitmapRect.Width(), BitmapRect.Height(), &amp;SourceDC, 0, 0, SRCCOPY );
        //clean up...
	SourceDC.SelectObject(pOldBitmap);
	SourceDC.DeleteDC();
</code></pre>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1274701</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1274701</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Fri, 27 Apr 2007 15:13:54 GMT</pubDate></item><item><title><![CDATA[Reply to Dimension eines CBitmap on Fri, 27 Apr 2007 15:17:28 GMT]]></title><description><![CDATA[<p>Ich habe gerade herausgefunden, dass es mit</p>
<pre><code class="language-cpp">BITMAP bmpInfo;
    DrawMeBmp.GetBitmap(&amp;bmpInfo);
    CRect BitmapRect(0,0,0,0);
    BitmapRect.right = bmpInfo.bmWidth;
    BitmapRect.bottom = bmpInfo.bmHeight;
</code></pre>
<p>Trotzdem wird in das überladene CStatic kein Bild eingefügt.</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1274709</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1274709</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Fri, 27 Apr 2007 15:17:28 GMT</pubDate></item><item><title><![CDATA[Reply to Dimension eines CBitmap on Sat, 28 Apr 2007 04:07:35 GMT]]></title><description><![CDATA[<p>Hallo,<br />
die Daten stehen in den Variablen biWidth, biHeight der Struktur BTMAPINFOHEADER.</p>
<p>Konkret, der Link, den du gepostet hast, guck mal unter Step 2: Drawing the bitmap.</p>
<p>BITMAP bm;<br />
bitmap.GetBitmap( &amp;bm );</p>
<p>bm.bmWidth &lt;-- daaaaaa<br />
bm.bmHeight &lt;-- und daaaaa</p>
<p>Tschau!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1274941</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1274941</guid><dc:creator><![CDATA[proggingmania]]></dc:creator><pubDate>Sat, 28 Apr 2007 04:07:35 GMT</pubDate></item><item><title><![CDATA[Reply to Dimension eines CBitmap on Sat, 28 Apr 2007 09:32:09 GMT]]></title><description><![CDATA[<p>Warum du allerdings nicht LoadImage nimmst und dann LR_FROMFILE angibst, ist mir ein Rätsel ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1275020</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1275020</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sat, 28 Apr 2007 09:32:09 GMT</pubDate></item><item><title><![CDATA[Reply to Dimension eines CBitmap on Sat, 28 Apr 2007 11:33:02 GMT]]></title><description><![CDATA[<p>(D)Evil schrieb:</p>
<blockquote>
<p>Warum du allerdings nicht LoadImage nimmst und dann LR_FROMFILE angibst, ist mir ein Rätsel ...</p>
</blockquote>
<p>Naja, weil ich kein MFC/Win32API Guru bin und nur das nutzen kann was man zu dem Thema findet. 'LoadImage' gehörte nicht zu den Aufrufen die ich gefunden habe.</p>
<p>Bei der Suche nach LoadImage bin ich dann auf folgenden Quellcode gestoßen</p>
<pre><code class="language-cpp">HANDLE hBitMap = ::LoadImage(0, &quot;c:\\mybmp.bmp&quot;,IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);

CBitmap bmp;
bmp.Attach((HBITMAP)hBitMap); // handle you got from LoadBitmap
</code></pre>
<p>was mir den Aufruf von</p>
<pre><code class="language-cpp">BOOL Result = BitmapOperations.LoadBMPImage((LPCTSTR)csFileName, DrawMeBmp, NULL );
</code></pre>
<p>erspart bzw ersetzt.</p>
<p>proggingmania schrieb:</p>
<blockquote>
<p>Konkret, der Link, den du gepostet hast, guck mal unter Step 2: Drawing the bitmap.</p>
</blockquote>
<p>Ups, das habe ich wohl übersehen. Vielen Dank, ich werde es ausprobieren.</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1275079</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1275079</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Sat, 28 Apr 2007 11:33:02 GMT</pubDate></item></channel></rss>