<?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[Probleme mit dem Kopieren von DC Daten]]></title><description><![CDATA[<p>Hi,</p>
<p>ich möchte gerne das was in meinem DC gespeichert ist, einem andere DC zuweisen. Allerdings klappt das nicht und ich versteh net genau warum.<br />
Genauer, es geht darum die Bildinformationen in eine Bitmap zu schreiben.</p>
<p>vielleicht sieht ja jemand den Fehler.<br />
Das ganze steht in der OnPaint drin nur zur Info</p>
<pre><code class="language-cpp">HDC hdc2;
   HBITMAP aBmp;
   BITMAPINFO bi;
   HGDIOBJ OldObj;
   void *dibvalues;
   BITMAPFILEHEADER bmfh;
   BITMAPINFOHEADER bmih;
   DWORD bytes_write;
   DWORD bytes_written;

     bmih.biSize=sizeof(BITMAPINFOHEADER);
     bmih.biHeight=rect1.Height();
     bmih.biWidth=rect1.Width();
     bmih.biPlanes=1;
     bmih.biBitCount=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;

   CPaintDC tDc( &amp;m_ctrlGlProgress ) ; 

     hdc2=CreateCompatibleDC(tDc.m_hDC);

      aBmp=CreateDIBSection(tDc.m_hDC,&amp;bi,DIB_RGB_COLORS,(void**)&amp;dibvalues,0,0);
      OldObj = SelectObject(hdc2,aBmp);
      BitBlt(hdc2,0,0,rect1.Width(),rect1.Height(),tDc.m_hDC,0,0,SRCCOPY);

      DC2Bitmap(tDc.m_hDC, rect1.Width(), rect1.Height(), &quot;tdcdc2.bmp&quot; ) ;
      DC2Bitmap(hdc2, rect1.Width(), rect1.Height(), &quot;hdc2.bmp&quot; ) ;
</code></pre>
<p>Mit den letzten beiden Zeilen geb ich den DC als Bitmap aus, nur sollte meiner Meinung nach beide Bitmaps identisch sein und net unterschiedlich !?!?! <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>jetzt gehts .... habs oben mal den funktionierende code reingeschrieben</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/71072/probleme-mit-dem-kopieren-von-dc-daten</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 14:42:18 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/71072.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 14 Apr 2004 15:05:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme mit dem Kopieren von DC Daten on Wed, 14 Apr 2004 15:24:12 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich möchte gerne das was in meinem DC gespeichert ist, einem andere DC zuweisen. Allerdings klappt das nicht und ich versteh net genau warum.<br />
Genauer, es geht darum die Bildinformationen in eine Bitmap zu schreiben.</p>
<p>vielleicht sieht ja jemand den Fehler.<br />
Das ganze steht in der OnPaint drin nur zur Info</p>
<pre><code class="language-cpp">HDC hdc2;
   HBITMAP aBmp;
   BITMAPINFO bi;
   HGDIOBJ OldObj;
   void *dibvalues;
   BITMAPFILEHEADER bmfh;
   BITMAPINFOHEADER bmih;
   DWORD bytes_write;
   DWORD bytes_written;

     bmih.biSize=sizeof(BITMAPINFOHEADER);
     bmih.biHeight=rect1.Height();
     bmih.biWidth=rect1.Width();
     bmih.biPlanes=1;
     bmih.biBitCount=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;

   CPaintDC tDc( &amp;m_ctrlGlProgress ) ; 

     hdc2=CreateCompatibleDC(tDc.m_hDC);

      aBmp=CreateDIBSection(tDc.m_hDC,&amp;bi,DIB_RGB_COLORS,(void**)&amp;dibvalues,0,0);
      OldObj = SelectObject(hdc2,aBmp);
      BitBlt(hdc2,0,0,rect1.Width(),rect1.Height(),tDc.m_hDC,0,0,SRCCOPY);

      DC2Bitmap(tDc.m_hDC, rect1.Width(), rect1.Height(), &quot;tdcdc2.bmp&quot; ) ;
      DC2Bitmap(hdc2, rect1.Width(), rect1.Height(), &quot;hdc2.bmp&quot; ) ;
</code></pre>
<p>Mit den letzten beiden Zeilen geb ich den DC als Bitmap aus, nur sollte meiner Meinung nach beide Bitmaps identisch sein und net unterschiedlich !?!?! <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>jetzt gehts .... habs oben mal den funktionierende code reingeschrieben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/501430</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/501430</guid><dc:creator><![CDATA[Jason_Frost]]></dc:creator><pubDate>Wed, 14 Apr 2004 15:24:12 GMT</pubDate></item></channel></rss>