<?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[8Bit Farb Bitmap in ein 8 Bit Graustufen Bitmap wandeln???]]></title><description><![CDATA[<p>Hi @ all</p>
<p>Ich habe folgendes problem...</p>
<p>Wie kann ich ein 8 Bit Farb Bitmap in ein 8 Bit Graustufen Bitmap wandeln??<br />
Hat jemand eine Idee?<br />
Ich hoffe mir kann jemand weiterhelfen?!</p>
<p>MFG Toby</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/176588/8bit-farb-bitmap-in-ein-8-bit-graustufen-bitmap-wandeln</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 05:03:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/176588.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 22 Mar 2007 15:48:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 8Bit Farb Bitmap in ein 8 Bit Graustufen Bitmap wandeln??? on Thu, 22 Mar 2007 15:48:18 GMT]]></title><description><![CDATA[<p>Hi @ all</p>
<p>Ich habe folgendes problem...</p>
<p>Wie kann ich ein 8 Bit Farb Bitmap in ein 8 Bit Graustufen Bitmap wandeln??<br />
Hat jemand eine Idee?<br />
Ich hoffe mir kann jemand weiterhelfen?!</p>
<p>MFG Toby</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1250607</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1250607</guid><dc:creator><![CDATA[toby138]]></dc:creator><pubDate>Thu, 22 Mar 2007 15:48:18 GMT</pubDate></item><item><title><![CDATA[Reply to 8Bit Farb Bitmap in ein 8 Bit Graustufen Bitmap wandeln??? on Thu, 22 Mar 2007 17:10:11 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Man könnte das hier verwenden.</p>
<pre><code class="language-cpp">void color2grey(Graphics::TBitmap *pBitmap)
{
  LOGPALETTE* plLogPal;
  int ilPaletteSize;  //  Grösse des Buffers für die LOGPALETTE-Struktur
  pBitmap-&gt;PixelFormat = pf8bit;
  try
  {
    // Speicherbedarf für die Palette berechnen und Speicher reservieren:
    ilPaletteSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * 255);
    plLogPal = (LOGPALETTE*) malloc(ilPaletteSize);

    if(plLogPal != NULL)
    {
      // Palette initialisieren:
      plLogPal-&gt;palVersion = 0x300;
      plLogPal-&gt;palNumEntries = 256;

      // Farben in der Palette mit Graustufen-Werten initialisieren:
      for (int ilColorIndex = 0; ilColorIndex &lt;= 255; ilColorIndex++)
      {
        plLogPal-&gt;palPalEntry[ilColorIndex].peRed = ilColorIndex;
        plLogPal-&gt;palPalEntry[ilColorIndex].peGreen = ilColorIndex;
        plLogPal-&gt;palPalEntry[ilColorIndex].peBlue = ilColorIndex;
        plLogPal-&gt;palPalEntry[ilColorIndex].peFlags = PC_NOCOLLAPSE;
      }

      // Palette erzeugen und zuweisen:
      HPALETTE hLogPal = CreatePalette(plLogPal);
      if (hLogPal) pBitmap-&gt;Palette = hLogPal;

      // Speicher wieder freigeben:
      free(plLogPal);
    }
  }
  catch ( ... ) { ;  }
}
</code></pre>
<p>Das habe ich irgendwo mal gefunden, weiß aber nicht mehr wo. Alternativ kannst du natürlich jeden Pixel einzeln wandeln.</p>
<pre><code class="language-cpp">TColor RGB2GRAY(const TColor col)
{
    double red = (col &amp; 0xFF) * 0.289 / 0xFF;
    double green = (col &amp; 0xFF00) * 0.607 / 0xFF00;
    double blue = (col &amp; 0xFF0000) * 0.114 / 0xFF0000;
    double gray_value = (red + green + blue);
    return TColor( int(gray_value*0xFF) + (int(gray_value*0xFF00) &amp; 0xFF00) +
           (int(gray_value*0xFF0000) &amp; 0xFF0000) );
}
//---------------------------------------------------------------------------
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1250670</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1250670</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 22 Mar 2007 17:10:11 GMT</pubDate></item><item><title><![CDATA[Reply to 8Bit Farb Bitmap in ein 8 Bit Graustufen Bitmap wandeln??? on Fri, 23 Mar 2007 07:23:29 GMT]]></title><description><![CDATA[<p>Vielen dank für deine hilfe!!!!!!!<br />
Ihr seit echt super!!!!! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>MFG Toby</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1250931</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1250931</guid><dc:creator><![CDATA[toby138]]></dc:creator><pubDate>Fri, 23 Mar 2007 07:23:29 GMT</pubDate></item></channel></rss>