<?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 manipulieren]]></title><description><![CDATA[<p>Ich möchte ein Programm schreiben mit dem ich ein Bitmap manipulieren kann. Mein Ansatz ist der:<br />
1. Größe des Bitmap hohlen<br />
2. Memory DC generieren<br />
3. Bitmap-Objekt in Memory DC laden und DC-Handle hohlen<br />
4. Untersuche jedes Bitmap-Pixel (GetPixel) und ändere es bei Bedarf (SetPixel)</p>
<pre><code class="language-cpp">//1. Größe des Bitmap
    BITMAP  BitmapInfo;
    pBitmap-&gt;GetBitmap(&amp;BitmapInfo); //pBitmap ist ein Bitmap-Pointer

    //2. memory device context generieren
    CClientDC	dc(this);
    CDC memoryDC; memoryDC.CreateCompatibleDC(&amp;dc);

    //3. Bitmap-Objekt in device context selektieren
    //   und Handle des device context hohlen
    HDC hDC = (HDC)memoryDC.SelectObject(pBitmap);

    COLORREF crWhite = RGB(255, 255, 255);
    COLORREF crGrey = RGB(212, 208, 200);
    COLORREF cr;

    int x = 0;
    for(int iY = 0; iY &lt; BitmapInfo.bmHeight; iY++)
    {
        for(int iX = 0; iX &lt; BitmapInfo.bmWidth; iX++)
        {
            //4. Hohle einzelnes Pixel -&gt; vergleiche und ändere
            if( (cr = GetPixel(hDC, iX, iY)) == crWhite)
                SetPixel(hDC , iX, iY, crGrey);
            /*BYTE B = GetBValue(cr);
            BYTE R = GetRValue(cr);
            BYTE G = GetGValue(cr);*/
            x++;
        }
    }
</code></pre>
<p>Nachdem ich die Manipulation durchgeführt habe (SetPixel) möchte ich nun mein ursprüngliches Bitmap 'pButton' überschreiben. Dazu empfehlt sich:</p>
<pre><code class="language-cpp">pButton-&gt;Attach(HGDIOBJ hObject);
</code></pre>
<p>Aber woher bekomme ich das HGDIOBJ?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/67847/bitmap-manipulieren</link><generator>RSS for Node</generator><lastBuildDate>Sat, 06 Jun 2026 13:35:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/67847.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 12 Mar 2004 08:23:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bitmap manipulieren on Fri, 12 Mar 2004 08:23:34 GMT]]></title><description><![CDATA[<p>Ich möchte ein Programm schreiben mit dem ich ein Bitmap manipulieren kann. Mein Ansatz ist der:<br />
1. Größe des Bitmap hohlen<br />
2. Memory DC generieren<br />
3. Bitmap-Objekt in Memory DC laden und DC-Handle hohlen<br />
4. Untersuche jedes Bitmap-Pixel (GetPixel) und ändere es bei Bedarf (SetPixel)</p>
<pre><code class="language-cpp">//1. Größe des Bitmap
    BITMAP  BitmapInfo;
    pBitmap-&gt;GetBitmap(&amp;BitmapInfo); //pBitmap ist ein Bitmap-Pointer

    //2. memory device context generieren
    CClientDC	dc(this);
    CDC memoryDC; memoryDC.CreateCompatibleDC(&amp;dc);

    //3. Bitmap-Objekt in device context selektieren
    //   und Handle des device context hohlen
    HDC hDC = (HDC)memoryDC.SelectObject(pBitmap);

    COLORREF crWhite = RGB(255, 255, 255);
    COLORREF crGrey = RGB(212, 208, 200);
    COLORREF cr;

    int x = 0;
    for(int iY = 0; iY &lt; BitmapInfo.bmHeight; iY++)
    {
        for(int iX = 0; iX &lt; BitmapInfo.bmWidth; iX++)
        {
            //4. Hohle einzelnes Pixel -&gt; vergleiche und ändere
            if( (cr = GetPixel(hDC, iX, iY)) == crWhite)
                SetPixel(hDC , iX, iY, crGrey);
            /*BYTE B = GetBValue(cr);
            BYTE R = GetRValue(cr);
            BYTE G = GetGValue(cr);*/
            x++;
        }
    }
</code></pre>
<p>Nachdem ich die Manipulation durchgeführt habe (SetPixel) möchte ich nun mein ursprüngliches Bitmap 'pButton' überschreiben. Dazu empfehlt sich:</p>
<pre><code class="language-cpp">pButton-&gt;Attach(HGDIOBJ hObject);
</code></pre>
<p>Aber woher bekomme ich das HGDIOBJ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/478852</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/478852</guid><dc:creator><![CDATA[q150022]]></dc:creator><pubDate>Fri, 12 Mar 2004 08:23:34 GMT</pubDate></item><item><title><![CDATA[Reply to Bitmap manipulieren on Fri, 12 Mar 2004 14:04:42 GMT]]></title><description><![CDATA[<p>Ganz davon einmal abgesehen, dass der obige Code nicht funktioniert <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> , hat jemand eine Idee oder einen Hinweis wie man so etwas macht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/479087</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/479087</guid><dc:creator><![CDATA[q150022]]></dc:creator><pubDate>Fri, 12 Mar 2004 14:04:42 GMT</pubDate></item></channel></rss>