<?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[Grauwerte in 8 Bit Bitmap werden nicht richtig gespeichert]]></title><description><![CDATA[<p>Hallo zusammen, ich hab das problem zwar im c++ Builder Forum gepostet, aber ich bin auf dieses verwiesen worden, es ist wahrscheinlich ein Mischproblem und hoffe hier kann mir jemand weiterhelfen.</p>
<p>Ich erzeuge eben ein 8 bit Bitmap und will nun die Bilder auf der Festplatte speichern vom Dunklen bis zum Hellen.</p>
<pre><code class="language-cpp">for(short i = 0 ; i &lt; 256 ; i++) {
      Graphics::TBitmap *smallImg = new Graphics::TBitmap();
      smallImg-&gt;Width = 10; smallImg-&gt;Height = 14;
      smallImg-&gt;PixelFormat = pf8bit;

      unsigned char *ptr;
      int x=0, y=0;
      ptr = static_cast&lt;BYTE*&gt;(smallImg-&gt;ScanLine[y]);
      for(int j=0; j &lt; (smallImg-&gt;Height * smallImg-&gt;Width); j++) {
         if(x == smallImg-&gt;Width) {
            y++;
            x = 0;
            ptr = static_cast&lt;BYTE*&gt;(smallImg-&gt;ScanLine[y]);
         }
         ptr[x]= (BYTE) i;
         x++;
      }
      smallImg-&gt;Palette = grayPal;
      smallImg-&gt;SaveToFile(&quot;clusterColor_&quot; + IntToStr(i) + &quot;.bmp&quot;);
   }
</code></pre>
<p>Die Palette hab ich mit folgendem Code erzeugt:</p>
<pre><code class="language-cpp">LOGPALETTE* pal = NULL;
    try {
       pal = (LOGPALETTE*) malloc( sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * 256);
       pal-&gt;palVersion = 0x300;
       pal-&gt;palNumEntries = 256;
       for(short i = 0 ; i &lt; 256 ; i++) {
          pal-&gt;palPalEntry[i].peRed =  (Byte)i;
          pal-&gt;palPalEntry[i].peGreen = pal-&gt;palPalEntry[i].peRed;
          pal-&gt;palPalEntry[i].peBlue = pal-&gt;palPalEntry[i].peRed;
       }
       grayPal = CreatePalette(pal);
    }
    __finally {
       delete pal;
    }
</code></pre>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox6174" checked="true" /><label for="checkbox6174">das Zeichen '\a' oder dez 97. Warum?</label></div></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/78218/grauwerte-in-8-bit-bitmap-werden-nicht-richtig-gespeichert</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 04:14:13 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/78218.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 29 Jun 2004 12:23:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Grauwerte in 8 Bit Bitmap werden nicht richtig gespeichert on Tue, 29 Jun 2004 12:23:28 GMT]]></title><description><![CDATA[<p>Hallo zusammen, ich hab das problem zwar im c++ Builder Forum gepostet, aber ich bin auf dieses verwiesen worden, es ist wahrscheinlich ein Mischproblem und hoffe hier kann mir jemand weiterhelfen.</p>
<p>Ich erzeuge eben ein 8 bit Bitmap und will nun die Bilder auf der Festplatte speichern vom Dunklen bis zum Hellen.</p>
<pre><code class="language-cpp">for(short i = 0 ; i &lt; 256 ; i++) {
      Graphics::TBitmap *smallImg = new Graphics::TBitmap();
      smallImg-&gt;Width = 10; smallImg-&gt;Height = 14;
      smallImg-&gt;PixelFormat = pf8bit;

      unsigned char *ptr;
      int x=0, y=0;
      ptr = static_cast&lt;BYTE*&gt;(smallImg-&gt;ScanLine[y]);
      for(int j=0; j &lt; (smallImg-&gt;Height * smallImg-&gt;Width); j++) {
         if(x == smallImg-&gt;Width) {
            y++;
            x = 0;
            ptr = static_cast&lt;BYTE*&gt;(smallImg-&gt;ScanLine[y]);
         }
         ptr[x]= (BYTE) i;
         x++;
      }
      smallImg-&gt;Palette = grayPal;
      smallImg-&gt;SaveToFile(&quot;clusterColor_&quot; + IntToStr(i) + &quot;.bmp&quot;);
   }
</code></pre>
<p>Die Palette hab ich mit folgendem Code erzeugt:</p>
<pre><code class="language-cpp">LOGPALETTE* pal = NULL;
    try {
       pal = (LOGPALETTE*) malloc( sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * 256);
       pal-&gt;palVersion = 0x300;
       pal-&gt;palNumEntries = 256;
       for(short i = 0 ; i &lt; 256 ; i++) {
          pal-&gt;palPalEntry[i].peRed =  (Byte)i;
          pal-&gt;palPalEntry[i].peGreen = pal-&gt;palPalEntry[i].peRed;
          pal-&gt;palPalEntry[i].peBlue = pal-&gt;palPalEntry[i].peRed;
       }
       grayPal = CreatePalette(pal);
    }
    __finally {
       delete pal;
    }
</code></pre>
<p><div class="plugin-markdown"><input type="checkbox" id="checkbox6174" checked="true" /><label for="checkbox6174">das Zeichen '\a' oder dez 97. Warum?</label></div></p>
]]></description><link>https://www.c-plusplus.net/forum/post/549773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/549773</guid><dc:creator><![CDATA[mattias]]></dc:creator><pubDate>Tue, 29 Jun 2004 12:23:28 GMT</pubDate></item><item><title><![CDATA[Reply to Grauwerte in 8 Bit Bitmap werden nicht richtig gespeichert on Wed, 30 Jun 2004 11:37:38 GMT]]></title><description><![CDATA[<p>bin ich mit diesem beitrag in diesem forum falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/550273</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/550273</guid><dc:creator><![CDATA[xxxxxxxxx]]></dc:creator><pubDate>Wed, 30 Jun 2004 11:37:38 GMT</pubDate></item></channel></rss>