<?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 auf festplatte speichern]]></title><description><![CDATA[<p>hi leute,</p>
<p>kann mir vielleicht jemand sagen wie ich ein bitmap als bmp-datei auf festplatte speichern kann ?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/61114/bitmap-auf-festplatte-speichern</link><generator>RSS for Node</generator><lastBuildDate>Wed, 03 Jun 2026 15:42:18 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/61114.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 11 Jan 2004 21:40:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to bitmap auf festplatte speichern on Sun, 11 Jan 2004 21:40:20 GMT]]></title><description><![CDATA[<p>hi leute,</p>
<p>kann mir vielleicht jemand sagen wie ich ein bitmap als bmp-datei auf festplatte speichern kann ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/434118</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/434118</guid><dc:creator><![CDATA[swmdennis]]></dc:creator><pubDate>Sun, 11 Jan 2004 21:40:20 GMT</pubDate></item><item><title><![CDATA[Reply to bitmap auf festplatte speichern on Sun, 11 Jan 2004 21:47:15 GMT]]></title><description><![CDATA[<p>bestimmt.</p>
<p>aber kannst du auch mal die suchfunktion benutzen, oder in der faq blättern, oder bei codeguru / codeproject schauen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/434124</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/434124</guid><dc:creator><![CDATA[alex-t]]></dc:creator><pubDate>Sun, 11 Jan 2004 21:47:15 GMT</pubDate></item><item><title><![CDATA[Reply to bitmap auf festplatte speichern on Sun, 11 Jan 2004 22:19:30 GMT]]></title><description><![CDATA[<p>Vor diesem Problem stand ich auch schonmal:</p>
<p><a href="http://www.smalleranimals.com/isource/isourcesample.htm#BMP24" rel="nofollow">http://www.smalleranimals.com/isource/isourcesample.htm#BMP24</a></p>
<p>Damit hab ichs geschafft</p>
<p>Wenn nicht:<br />
<a href="http://www.codeguru.com/bitmap/" rel="nofollow">http://www.codeguru.com/bitmap/</a><br />
<a href="http://www.nikis.de/181/vcnet.htm" rel="nofollow">http://www.nikis.de/181/vcnet.htm</a><br />
<a href="http://people.freenet.de/cpp-programming.de.vu/quellcodes/code17.html" rel="nofollow">http://people.freenet.de/cpp-programming.de.vu/quellcodes/code17.html</a></p>
<p>So das sollte reichen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":-)"
      alt="🙂"
    /><br />
greetz BigMama</p>
]]></description><link>https://www.c-plusplus.net/forum/post/434149</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/434149</guid><dc:creator><![CDATA[bigmama]]></dc:creator><pubDate>Sun, 11 Jan 2004 22:19:30 GMT</pubDate></item><item><title><![CDATA[Reply to bitmap auf festplatte speichern on Mon, 12 Jan 2004 11:10:32 GMT]]></title><description><![CDATA[<p>zum 4. Mal in letzer Zeit:</p>
<pre><code class="language-cpp">BOOL WriteBitmap( LPTSTR szFile, HBITMAP hbitmap, HDC memdc) 
{ 
      BITMAP  bmp; 
      if(GetObject(hbitmap, sizeof(BITMAP), &amp;bmp)) 
      { 
        BITMAPINFOHEADER BmpInfoHdr; 
     BITMAPFILEHEADER BmpFileHdr; 
         BmpInfoHdr.biSize = sizeof(BITMAPINFOHEADER); 
        BmpInfoHdr.biWidth = bmp.bmWidth; 
    BmpInfoHdr.biHeight = bmp.bmHeight; 
        BmpInfoHdr.biPlanes = bmp.bmPlanes; 
    BmpInfoHdr.biBitCount = 24; 
        BmpInfoHdr.biCompression    = BI_RGB; 
         BmpInfoHdr.biSizeImage        = bmp.bmWidth*bmp.bmHeight*3; 
         BmpFileHdr.bfType        = 0x4d42; 
         BmpFileHdr.bfReserved1        = 0; 
         BmpFileHdr.bfReserved2        = 0; 
         BmpFileHdr.bfOffBits = sizeof(BITMAPFILEHEADER)+sizeof (BITMAPINFOHEADER); 
        BmpFileHdr.bfSize = BmpFileHdr.bfOffBits+BmpInfoHdr.biSizeImage; 
        bmp.bmBits = (void*)GlobalAlloc(GMEM_FIXED, BmpInfoHdr.biSizeImage); 
        if(GetDIBits(memdc, hbitmap, 0, BmpInfoHdr.biHeight, bmp.bmBits, (BITMAPINFO*)&amp;BmpInfoHdr, DIB_RGB_COLORS) == BmpInfoHdr.biHeight) 
        { 
            HANDLE hFile = CreateFile(szFile, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL); 
            if(hFile != INVALID_HANDLE_VALUE)  { 
            DWORD dwTmp; 
            WriteFile(hFile, &amp;BmpFileHdr, sizeof(BITMAPFILEHEADER), &amp;dwTmp, NULL); 
            WriteFile(hFile, &amp;BmpInfoHdr, sizeof(BITMAPINFOHEADER), &amp;dwTmp, NULL); 
            WriteFile(hFile, bmp.bmBits,  BmpInfoHdr.biSizeImage,   &amp;dwTmp, NULL); 
        } 
        CloseHandle(hFile); 
    } 
    GlobalFree(bmp.bmBits); 
    return TRUE; 
  } 
  return FALSE; 
}
</code></pre>
<p><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="😉"
    /> <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="😉"
    /></p>
<p>Grüße Rapha</p>
]]></description><link>https://www.c-plusplus.net/forum/post/434375</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/434375</guid><dc:creator><![CDATA[Rapha]]></dc:creator><pubDate>Mon, 12 Jan 2004 11:10:32 GMT</pubDate></item><item><title><![CDATA[Reply to bitmap auf festplatte speichern on Mon, 12 Jan 2004 15:25:31 GMT]]></title><description><![CDATA[<p>[code]void CBMPDoc::OnSavebmp()<br />
{<br />
// TODO: Code für Befehlsbehandlungsroutine hier einfügen</p>
<p>CRect rRect;<br />
CString sFilename;</p>
<p>POSITION pos = GetFirstViewPosition();<br />
CBMPView *pView = (CBMPView*) GetNextView(pos);</p>
<p>static char BASED_CODE szFilter[] = &quot;Bitmap-Dateien (<em>.bmp)|</em>.bmp||&quot;;<br />
//dialogfeld öffnen erzeugen<br />
CFileDialog ldFile(false, &quot;.bmp&quot;, m_sBitmap, OFN_HIDEREADONLY |<br />
OFN_OVERWRITEPROMPT, szFilter);</p>
<p>//dialogfeld öffnen anzeigen<br />
if(ldFile.DoModal() == IDOK){<br />
//Gewählten dateinamen ermitteln<br />
sFilename = ldFile.GetPathName();<br />
}</p>
<p>if(pView){</p>
<p>CDC *pDC;<br />
pDC = pView-&gt;GetDC();//gerätekontext holen<br />
pView-&gt;GetClientRect(&amp;rRect);//größe des fensters</p>
<p>DC2Bitmap(*pDC, rRect.Width(), rRect.Height(),&quot;c:\\tst.bmp&quot;);</p>
<p>}<br />
}</p>
<p>//erzeugt aus gerätekontext ein bitmap und speichert es auf festplatte (gefunden)<br />
int CBMPDoc::DC2Bitmap(HDC hdc, int width, int height, char *filename)<br />
{<br />
HDC hdc2;<br />
HBITMAP aBmp;<br />
BITMAPINFO bi;<br />
HGDIOBJ OldObj;<br />
void *dibvalues;<br />
HANDLE fileHandle;</p>
<p>BITMAPFILEHEADER bmfh;<br />
BITMAPINFOHEADER bmih;<br />
DWORD bytes_write;<br />
DWORD bytes_written;</p>
<p>hdc2=CreateCompatibleDC(hdc);</p>
<p>ZeroMemory(&amp;bmih,sizeof(BITMAPINFOHEADER));<br />
bmih.biSize=sizeof(BITMAPINFOHEADER);<br />
bmih.biHeight=height;<br />
bmih.biWidth=width;<br />
bmih.biPlanes=1;<br />
bmih.biBitCount=24;<br />
bmih.biCompression=BI_RGB;<br />
bmih.biSizeImage = ((((bmih.biWidth * bmih.biBitCount) + 31)<br />
&amp; ~31) &gt;&gt; 3) * bmih.biHeight;</p>
<p>bmih.biXPelsPerMeter = 0;<br />
bmih.biYPelsPerMeter = 0;<br />
bmih.biClrImportant = 0;</p>
<p>bi.bmiHeader=bmih;</p>
<p>aBmp=CreateDIBSection(hdc,&amp;bi,DIB_RGB_COLORS,(void**)&amp;dibvalues,0,0);</p>
<p>if(aBmp==NULL)<br />
{<br />
OutputDebugString(&quot;CreateDIBSection failed!\n&quot;);<br />
return 0;<br />
}</p>
<p>OldObj=SelectObject(hdc2,aBmp);<br />
BitBlt(hdc2,0,0,width,height,hdc,0,0,SRCCOPY);</p>
<p>ZeroMemory(&amp;bmfh,sizeof(BITMAPFILEHEADER));<br />
bmfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);<br />
bmfh.bfSize=(3*bmih.biHeight*bmih.biWidth)+sizeof(BITMAPFILEHEADER)<br />
+sizeof(BITMAPINFOHEADER);<br />
bmfh.bfType=0x4d42;<br />
bmfh.bfReserved1 = 0;<br />
bmfh.bfReserved2 = 0;</p>
<p>fileHandle=CreateFile(filename,GENERIC_READ|GENERIC_WRITE,(DWORD)0,NULL,<br />
CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,(HANDLE) NULL);</p>
<p>if (fileHandle==INVALID_HANDLE_VALUE)<br />
{<br />
OutputDebugString(&quot;CreateFile failed!\n&quot;);<br />
return 0;<br />
}</p>
<p>bytes_write=sizeof(BITMAPFILEHEADER);</p>
<p>if (!WriteFile(fileHandle,(void*)&amp;bmfh,bytes_write,&amp;bytes_written,NULL))<br />
{<br />
OutputDebugString(&quot;WriteFile failed!\n&quot;);<br />
return 0;<br />
}</p>
<p>bytes_write=sizeof(BITMAPINFOHEADER);</p>
<p>if(!WriteFile(fileHandle,(void*)&amp;bmih,bytes_write,&amp;bytes_written,NULL))<br />
{<br />
OutputDebugString(&quot;WriteFile failed!\n&quot;);<br />
return 0;<br />
}</p>
<p>bytes_write=bmih.biSizeImage;</p>
<p>if(!WriteFile(fileHandle,(void*)dibvalues,<br />
bytes_write,&amp;bytes_written,NULL))<br />
{<br />
OutputDebugString(&quot;WriteFile failed!\n&quot;);<br />
return 0;<br />
}</p>
<p>CloseHandle(fileHandle);</p>
<p>DeleteObject(SelectObject(hdc2,OldObj));<br />
DeleteDC(hdc2);</p>
<p>return 1;<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/434567</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/434567</guid><dc:creator><![CDATA[swmdennis]]></dc:creator><pubDate>Mon, 12 Jan 2004 15:25:31 GMT</pubDate></item><item><title><![CDATA[Reply to bitmap auf festplatte speichern on Mon, 12 Jan 2004 15:27:56 GMT]]></title><description><![CDATA[<p>hi leute danke für eure hilfe ich hab was gefunden.<br />
den code von dir rapha hab ich ausprobiert hat aber leider nicht geklappt.<br />
ich hab folgendes eingegeben<br />
CDC *pDC;<br />
pDC = pView-&gt;GetDC();//gerätekontext holen<br />
pView-&gt;GetClientRect(&amp;rRect);//größe des fensters<br />
CBitmap bmp;<br />
bmp.CreateCompatibleBitmap(pDC,rRect.Width(), rRect.Height());<br />
pDC-&gt;SelectObject(bmp);<br />
WriteBitmap(&quot;c:\\tst.bmp&quot;,(HBITMAP) bmp,*pDC);<br />
das hat dazu geführt das mein programm abstürz. hab auch keine ahnung warum?</p>
<p>ich hab hier einen code der funktioniert.<br />
ich hab nun aber das problem, dass wenn ich OnSavebmp() zum 2. mal aufrufe,<br />
dann speichert er auch das dialogfeld ldFile als bmp. woran kann das liegen ??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/434571</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/434571</guid><dc:creator><![CDATA[swmdennis]]></dc:creator><pubDate>Mon, 12 Jan 2004 15:27:56 GMT</pubDate></item><item><title><![CDATA[Reply to bitmap auf festplatte speichern on Mon, 12 Jan 2004 15:56:27 GMT]]></title><description><![CDATA[<p>Hi,<br />
du musst ein MemoryDC erstellen und den Inhalt von pDC da hineinblitten.<br />
Ist ganz einfach</p>
<p>Ich hab dir ne kleine Beispielanwendung (5 Min) geschrieben:<br />
Einfach die BitmapTest runterladen: <a href="http://mitglied.lycos.de/rame03/files.htm" rel="nofollow">http://mitglied.lycos.de/rame03/files.htm</a></p>
<p>Grüße Rapha</p>
]]></description><link>https://www.c-plusplus.net/forum/post/434596</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/434596</guid><dc:creator><![CDATA[Rapha]]></dc:creator><pubDate>Mon, 12 Jan 2004 15:56:27 GMT</pubDate></item><item><title><![CDATA[Reply to bitmap auf festplatte speichern on Mon, 12 Jan 2004 17:35:25 GMT]]></title><description><![CDATA[<p>ich hab folgendes eingegeben, das führt aber auch zum absturz.<br />
speichert das bild zwar, aber auch das dialogfeld von ldFile, obwohl ich<br />
WriteBitmap später aufrufe. was kann man denn machen damit er das dialogfeld<br />
nicht mehr anzeigt ?</p>
<p>[cpp]POSITION pos = GetFirstViewPosition();<br />
CBMPView *pView = (CBMPView*) GetNextView(pos);<br />
static char BASED_CODE szFilter[] = &quot;Bitmap-Dateien (<em>.bmp)|</em>.bmp||&quot;;</p>
<p>CFileDialog ldFile(false, &quot;.bmp&quot;, m_sBitmap, OFN_HIDEREADONLY |<br />
OFN_OVERWRITEPROMPT, szFilter);</p>
<p>if(ldFile.DoModal() == IDOK){<br />
//Gewählten dateinamen ermitteln<br />
sFilename = ldFile.GetPathName();<br />
}<br />
if(pView){<br />
CDC *pDC,DC;<br />
CBitmap Bitmap;</p>
<p>pDC = pView-&gt;GetDC();//gerätekontext holen<br />
CRect rRect;<br />
pView-&gt;GetClientRect(&amp;rRect);//größe des fensters<br />
DC.CreateCompatibleDC(pDC);<br />
if(!Bitmap.CreateCompatibleBitmap(pDC, rRect.right - rRect.left, rRect.bottom - rRect.top))<br />
{<br />
DC.DeleteDC();<br />
AfxMessageBox(&quot;Bitmap konnte nicht erstellt werden&quot;);<br />
return;<br />
}</p>
<p>DC.SelectObject(&amp;Bitmap);<br />
DC.BitBlt(0, 0, rRect.right - rRect.left, rRect.bottom - rRect.top, pDC, 0, 0, SRCCOPY);</p>
<p>// Bitmap schreiben:<br />
WriteBitmap(&quot;C:\\Test.bmp&quot;, (HBITMAP) Bitmap, (HDC) DC);</p>
<p>// Und noch aufräumen<br />
Bitmap.DeleteObject();<br />
DC.DeleteDC();<br />
pDC = NULL;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/434704</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/434704</guid><dc:creator><![CDATA[swmdennis]]></dc:creator><pubDate>Mon, 12 Jan 2004 17:35:25 GMT</pubDate></item><item><title><![CDATA[Reply to bitmap auf festplatte speichern on Mon, 12 Jan 2004 19:14:39 GMT]]></title><description><![CDATA[<p>Hm, an dem Code scheint alles in Ordnung zu sein (achja, du musst dein pDC noch richtig löschen: pView-&gt;ReleaseDC(pDC) und dann pDC = NULL;).</p>
<p>Gib mal etwas mehr Code.<br />
Lass die Anwendung im Debug Modus laufen - gibt es irgendwelche Fehlermeldungen?<br />
Du sagst, dass deine Anwendung abstürzt, wie genau macht sie das?</p>
<p>Wenn das mit dem Dialogfeld nicht geht (müsste eigendlich schon), dann könntest du einen Timer einbauen oder IdFile.ShowWindow(SW_HIDE); versuchen</p>
<p>Grüße Rapha</p>
]]></description><link>https://www.c-plusplus.net/forum/post/434833</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/434833</guid><dc:creator><![CDATA[Rapha]]></dc:creator><pubDate>Mon, 12 Jan 2004 19:14:39 GMT</pubDate></item><item><title><![CDATA[Reply to bitmap auf festplatte speichern on Mon, 12 Jan 2004 21:08:37 GMT]]></title><description><![CDATA[<p>er geht bis zu GlobalFree(bmp.bmBits); von WriteBitmap und gibt anschließend folgende meldung aus</p>
<p>&quot;Nicht abgefangene Ausnahme in SWM.exe (KERNEL32.DLL): 0xC0000005: Access Violation.&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/434989</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/434989</guid><dc:creator><![CDATA[swmdennis]]></dc:creator><pubDate>Mon, 12 Jan 2004 21:08:37 GMT</pubDate></item><item><title><![CDATA[Reply to bitmap auf festplatte speichern on Tue, 13 Jan 2004 11:36:34 GMT]]></title><description><![CDATA[<p>Hm, die Funktion ist vollkommen in Ordung <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>Gib mal ein paar Informationen mehr an.<br />
Dein OS, die Version von MSVC++, Version des Service Packs, usw.</p>
<p>Hast du dir mein Beispielprojekt angeschaut?<br />
Wenn du dich Schritt für Schritt daran entlanghangelst, müsste es eingendlich gehen.</p>
<p>Grüße Rapha</p>
]]></description><link>https://www.c-plusplus.net/forum/post/435252</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/435252</guid><dc:creator><![CDATA[Rapha]]></dc:creator><pubDate>Tue, 13 Jan 2004 11:36:34 GMT</pubDate></item></channel></rss>