<?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[SetTransparent auf Bitmap anwenden]]></title><description><![CDATA[<p>Nach vielem gegoogle und suchen in diversen Sites bitte ich einfach mal<br />
hier um Hilfe.</p>
<p>Ich habe eine Ressource IDB_BITMAP1 die ich in der Farbe &quot;schwarz&quot;<br />
transparent darstellen möchte. Ich finde einfach keine für mich verständliche<br />
Erklärung, wie man das anstellen soll.</p>
<p>Kann mir jemand aus diesem Forum dabei auf die Sprünge helfen ?<br />
Ich habe zwar schon Demos gefunden, die kann ich aber weder nachbauen,<br />
noch wirklich nachvollziehen.</p>
<p>Ich brauche wohl COLORREF und muss dort mit RGB etwas wie 0,0,255<br />
angeben um erstmal schwarz zu definieren. Aber dann hört es auf.<br />
Brauche ich eine HBITMAP Variable um dieser dann SetTransparentColor<br />
oder SetTransparent zu übergeben ? Und wenn ja, wie ist dafür der Ansatz ?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/123587/settransparent-auf-bitmap-anwenden</link><generator>RSS for Node</generator><lastBuildDate>Mon, 06 Jul 2026 23:54:27 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/123587.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 18 Oct 2005 09:52:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to SetTransparent auf Bitmap anwenden on Tue, 18 Oct 2005 09:52:51 GMT]]></title><description><![CDATA[<p>Nach vielem gegoogle und suchen in diversen Sites bitte ich einfach mal<br />
hier um Hilfe.</p>
<p>Ich habe eine Ressource IDB_BITMAP1 die ich in der Farbe &quot;schwarz&quot;<br />
transparent darstellen möchte. Ich finde einfach keine für mich verständliche<br />
Erklärung, wie man das anstellen soll.</p>
<p>Kann mir jemand aus diesem Forum dabei auf die Sprünge helfen ?<br />
Ich habe zwar schon Demos gefunden, die kann ich aber weder nachbauen,<br />
noch wirklich nachvollziehen.</p>
<p>Ich brauche wohl COLORREF und muss dort mit RGB etwas wie 0,0,255<br />
angeben um erstmal schwarz zu definieren. Aber dann hört es auf.<br />
Brauche ich eine HBITMAP Variable um dieser dann SetTransparentColor<br />
oder SetTransparent zu übergeben ? Und wenn ja, wie ist dafür der Ansatz ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/894910</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894910</guid><dc:creator><![CDATA[Bullfrog]]></dc:creator><pubDate>Tue, 18 Oct 2005 09:52:51 GMT</pubDate></item><item><title><![CDATA[Reply to SetTransparent auf Bitmap anwenden on Tue, 18 Oct 2005 10:24:57 GMT]]></title><description><![CDATA[<p>Wie zeichnest du denn nachher dein Bitmap? Schau dir mal <a href="http://msdn.microsoft.com/library/en-us/gdi/bitmaps_2y9g.asp" rel="nofollow">TransparentBlt</a> an.<br />
BTW: Schwarz wäre wenn dann aber 0,0,0</p>
]]></description><link>https://www.c-plusplus.net/forum/post/894945</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/894945</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Tue, 18 Oct 2005 10:24:57 GMT</pubDate></item><item><title><![CDATA[Reply to SetTransparent auf Bitmap anwenden on Tue, 18 Oct 2005 12:07:14 GMT]]></title><description><![CDATA[<p>Ich habe das ursprünglich in einem MFC-Projekt.<br />
Ziel ist das angezeigte Bitmap mit der ID IDB_BITMAP1<br />
am Rand transparent zu bekommen. Der Rand ist schwarz und soll weg.<br />
Das Bild soll danach dann nur noch selbst zu sehen sein.</p>
<p>Wenn es für einen erfahrenen Programmierer hier im Forum<br />
möglich wäre einen Beispielcode zu posten, will ich mich<br />
daran weiter versuchen. Momentan komme ich selbst einfach<br />
keinen Schritt weiter.</p>
<p>Ich habe momentan abgesehen von den viel unübersichtlichen<br />
Beispielprojekten nur folgendes (hoffentlich) verstanden:</p>
<p>Ich brauche auf HBITMAP den Zugriff auf mein Bitmap:</p>
<pre><code class="language-cpp">HBITMAP bmp1=::LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1));
</code></pre>
<p>Dann muss ich wohl das ganze Bitmap nochmal in ein HBITMAP überführen<br />
und dann irgendwie CreateBitmap verwenden und dem Bitmap dann die<br />
Transparenz verpassen. Habe ich das jetzt richtig erklärt ?</p>
<p>Uff...also selbst die sonst gut verständlichen und dokumentierten Klassen<br />
bei Codeproject überfordern mich in dieser Sache ehrlich gesagt total. <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="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/895044</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/895044</guid><dc:creator><![CDATA[Bullfrog]]></dc:creator><pubDate>Tue, 18 Oct 2005 12:07:14 GMT</pubDate></item><item><title><![CDATA[Reply to SetTransparent auf Bitmap anwenden on Tue, 18 Oct 2005 12:42:39 GMT]]></title><description><![CDATA[<p>Mal so auf die Schnelle (Fehler nicht ausgeschlossen):</p>
<pre><code class="language-cpp">hdc = BeginPaint (hwnd, &amp;ps);
HBITMAP hBmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP1));
BITMAP bmpInfo;
GetObject(hBmp,sizeof(BITMAP),&amp;bmpInfo);
HDC hdcMem = CreateCompatibleDC(hdc);
SelectObject(hdcMem,hBmp);
TransparentBlt(hdc,0,0,bmpInfo.bmWidth,bmpInfo.bmHeight,hdcMem,0,0,bmpInfo.bmWidth,bmpInfo.bmHeight,RGB(0,0,0));
DeleteObject(hBmp);
DeleteDC(hdcMem);
EndPaint (hwnd, &amp;ps);
</code></pre>
<p>Das ist der Code aus WM_PAINT - der Übersichtlichkeit halber hab ich mal alles da rein gepackt. Von der Effizienz her wäre es wohl sinnvoller das Bitmap z.B. bei WM_CREATE zu laden. Und nicht vergessen Msimg32.lib zu linken...</p>
<p>edit: hInst wäre dann bei dir AfxGetInstanceHandle() <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>
]]></description><link>https://www.c-plusplus.net/forum/post/895085</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/895085</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Tue, 18 Oct 2005 12:42:39 GMT</pubDate></item><item><title><![CDATA[Reply to SetTransparent auf Bitmap anwenden on Tue, 18 Oct 2005 13:39:23 GMT]]></title><description><![CDATA[<p>Ich muss also noch HDC, PAINTSRUCT und HWND definieren oder?</p>
<pre><code class="language-cpp">HDC hdc;
PAINTSTRUCT ps;
HWND hwnd;

hdc = BeginPaint (hwnd, &amp;ps);
HBITMAP hBmp = ::LoadBitmap(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1));
BITMAP bmpInfo;
GetObject(hBmp,sizeof(BITMAP),&amp;bmpInfo);
HDC hdcMem = ::CreateCompatibleDC(hdc);
SelectObject(hdcMem,hBmp);
TransparentBlt(hdc,0,0,bmpInfo.bmWidth,bmpInfo.bmHeight,hdcMem,0,0,bmpInfo.bmWidth,bmpInfo.bmHeight,RGB(0,0,0));
DeleteObject(hBmp);
DeleteDC(hdcMem);
::EndPaint (hwnd, &amp;ps);
</code></pre>
<p>Nur mein Bitmap will nicht den schwarzen Bereich transparent setzen <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="😞"
    /><br />
Es passiert nichts. Was muss ergänzend noch gemacht werden?<br />
Ich check das noch nicht wirklich. Wie muss ich hwnd definieren (=NULL)?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/895145</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/895145</guid><dc:creator><![CDATA[Bullfrog]]></dc:creator><pubDate>Tue, 18 Oct 2005 13:39:23 GMT</pubDate></item><item><title><![CDATA[Reply to SetTransparent auf Bitmap anwenden on Tue, 18 Oct 2005 15:31:56 GMT]]></title><description><![CDATA[<p>Der Code von flenders zeichnet ein Bitmap in ein Fenster und muss im richtigen Moment ausgeführt werden. Er ändert nicht das Bitmap, so dass danach schwarz transparent ist, was du erwartet hast, oder?<br />
Du könntest unterstützend mal deinen gesamten Code zeigen oder zumindest die relevanten Funktionen.</p>
<p>BTW: Warum fragst du nicht im MFC-Forum?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/895259</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/895259</guid><dc:creator><![CDATA[D*niel *chumann]]></dc:creator><pubDate>Tue, 18 Oct 2005 15:31:56 GMT</pubDate></item><item><title><![CDATA[Reply to SetTransparent auf Bitmap anwenden on Tue, 18 Oct 2005 16:06:42 GMT]]></title><description><![CDATA[<p>Vielleicht hilft folgender Beitrag weiter:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39066.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-39066.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/895291</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/895291</guid><dc:creator><![CDATA[guenni81]]></dc:creator><pubDate>Tue, 18 Oct 2005 16:06:42 GMT</pubDate></item><item><title><![CDATA[Reply to SetTransparent auf Bitmap anwenden on Wed, 19 Oct 2005 06:36:28 GMT]]></title><description><![CDATA[<p>Ich hätt auch ne frage:<br />
Gibts eine Funktion/Methode mit der man eine Farbe zu m-% transparent machen kann?</p>
<p>Also zum beispiel nur 50% durchsichtig?</p>
<p>Weil ich verwende TransparentBlt aber damit wird die Farbe einfach ausgeblendet und für Schatten-Effekte oder dgl. eignet sich das natürlich nicht.</p>
<p>MfG Kuldren</p>
]]></description><link>https://www.c-plusplus.net/forum/post/895768</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/895768</guid><dc:creator><![CDATA[Kuldren]]></dc:creator><pubDate>Wed, 19 Oct 2005 06:36:28 GMT</pubDate></item><item><title><![CDATA[Reply to SetTransparent auf Bitmap anwenden on Wed, 19 Oct 2005 06:57:34 GMT]]></title><description><![CDATA[<p>da gibts AlphaBlend für. TransparentBlt is im PSDK glaub ich auch als deprecated oder speicherbuggy bezeichnet oder so, soll man also eigentlich nicht mehr nehmen, oder die ham das in neueren win-vrsionen gefoxt, kA</p>
]]></description><link>https://www.c-plusplus.net/forum/post/895787</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/895787</guid><dc:creator><![CDATA[Maxi]]></dc:creator><pubDate>Wed, 19 Oct 2005 06:57:34 GMT</pubDate></item><item><title><![CDATA[Reply to SetTransparent auf Bitmap anwenden on Wed, 19 Oct 2005 07:04:05 GMT]]></title><description><![CDATA[<blockquote>
<p>Use AlphaBlend to specify 32 bits-per-pixel bitmaps with transparency.</p>
</blockquote>
<p>Zum selber zeichnen bietet dir <a href="http://msdn.microsoft.com/library/en-us/gdicpp/gdiplus/gdiplus.asp" rel="nofollow">GDI+</a> einige Funktionen <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="🙂"
    /></p>
<p>Maxi schrieb:</p>
<blockquote>
<p>da gibts AlphaBlend für. TransparentBlt is im PSDK glaub ich auch als deprecated oder speicherbuggy bezeichnet oder so, soll man also eigentlich nicht mehr nehmen, oder die ham das in neueren win-vrsionen gefoxt, kA</p>
</blockquote>
<p>Das steht nur zu Windows 95/98:</p>
<blockquote>
<p>TransparentBlt contains a memory leak that can exhaust system resources. To draw a transparent bitmap using BitBlt, see <a href="http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B79212" rel="nofollow">Knowledge Base article 79212</a>.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/895793</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/895793</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Wed, 19 Oct 2005 07:04:05 GMT</pubDate></item></channel></rss>