<?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[Frage bezüglich des Schreibens einer BMP datei in Datei]]></title><description><![CDATA[<p>Hallo, versuche gerade eine BMP datei via fstream in eine andere Datei zu schreiben. Zwar erzeugt der Code keinen Fehler und IRGENDWAS wird auch in die Datei geschrieben/kopiert, jedoch scheinbar nur Teile. Das Laden in die Bitmapklasse dürfte aufjedenfall funktionieren.</p>
<p>Hiermal der Code, sowie ein Auszug aus der Klasse die zum laden des Bitmaps benutzt wird(nicht von mir):</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;iostream&gt;
#include &quot;Bitmap.h&quot;
using namespace std;

int main () 
{
  Bitmap test(&quot;test.bmp&quot;);
 cout &lt;&lt; endl;
 fstream myfile(&quot;temp.bmp&quot;,ios::out | ios::binary);
 myfile.write((char*)&amp;(test.bmfh),sizeof(BitmapFileHeader));
 myfile.write((char*)&amp;(test.bmih),sizeof(BitmapInfoHeader));
 myfile.write((char*)(test.colours),sizeof(RGBQuad)*256);
 myfile.write(test.data,test.dataSize);

 /*
  // open it for output then write to it
  fstream myfile;
  myfile.open(&quot;test.txt&quot;,ios::out | ios::trunc);

  if (myfile.is_open())   {
     myfile &lt;&lt; &quot;This outputting a line.\n&quot;;
     myfile.close();
  }
 */
 myfile.close();
 getchar();
  return 0;
}
</code></pre>
<pre><code class="language-cpp">//load a bitmap from a file and represent it correctly
//in memory
bool Bitmap::loadBMP(char* file) {
    FILE *in;                  //file stream for reading
    char *tempData;       //temp storage for image data
    int numColours;            //total available colours

    //bitmap is not loaded yet
    loaded=false;
    //make sure memory is not lost
    if(colours!=0) {
        delete[] colours;
    }
    if(data!=0) {
        delete[] data;
    }

    //open the file for reading in binary mode
    in=fopen(file,&quot;rb&quot;);

    //if the file does not exist return in error
    if(in==NULL) {
        error=&quot;File not found&quot;;
        fclose(in);
        return false;
    }

    //read in the entire BITMAPFILEHEADER
    fread(&amp;bmfh,sizeof(BitmapFileHeader),1,in);
	cout &lt;&lt; &quot;sizeof(BitmapFileHeader)=&quot; &lt;&lt; sizeof(BitmapFileHeader) &lt;&lt; endl;
    //check for the magic number that says this is a bitmap
    if(bmfh.bfType!=BITMAP_MAGIC_NUMBER) {
        error=&quot;File is not in DIB format&quot;;
        fclose(in);
        return false;
    }

    //read in the entire BITMAPINFOHEADER
    fread(&amp;bmih,sizeof(BitmapInfoHeader),1,in);
	cout &lt;&lt; &quot;sizeof(BitmapInfoHeader)=&quot; &lt;&lt; sizeof(BitmapInfoHeader) &lt;&lt; endl;

    //save the width, height and bits per pixel for external use
    width=bmih.biWidth;
    height=bmih.biHeight;
    bpp=bmih.biBitCount;
	cout &lt;&lt; &quot;biBitCount      =&quot; &lt;&lt; bmih.biBitCount &lt;&lt; endl;
	cout &lt;&lt; &quot;biClrImportant  =&quot; &lt;&lt; bmih.biClrImportant &lt;&lt; endl;
	cout &lt;&lt; &quot;biClrUsed       =&quot; &lt;&lt; bmih.biClrUsed &lt;&lt; endl;
	cout &lt;&lt; &quot;biCompression   =&quot; &lt;&lt; bmih.biCompression &lt;&lt; endl;
	cout &lt;&lt; &quot;biHeight        =&quot; &lt;&lt; bmih.biHeight &lt;&lt; endl;
	cout &lt;&lt; &quot;biPlanes        =&quot; &lt;&lt; bmih.biPlanes &lt;&lt; endl;
	cout &lt;&lt; &quot;biSize          =&quot; &lt;&lt; bmih.biSize &lt;&lt; endl;
	cout &lt;&lt; &quot;biSizeImage     =&quot; &lt;&lt; bmih.biSizeImage &lt;&lt; endl;
	cout &lt;&lt; &quot;biWidth         =&quot; &lt;&lt; bmih.biWidth &lt;&lt; endl;
	cout &lt;&lt; &quot;biXPelsPerMeter =&quot; &lt;&lt; bmih.biXPelsPerMeter &lt;&lt; endl;
	cout &lt;&lt; &quot;biYPelsPerMeter =&quot; &lt;&lt; bmih.biYPelsPerMeter &lt;&lt; endl;

    //calculate the size of the image data with padding
    dataSize=(width*height*(unsigned int)(bmih.biBitCount/8.0));

    //calculate the number of available colours
    numColours=1&lt;&lt;bmih.biBitCount;
    cout &lt;&lt; numColours &lt;&lt; endl;
    //if the bitmap is not 8 bits per pixel or more
    //return in error
    if(bpp&lt;8) {
        error=&quot;File is not 8 or 24 bits per pixel&quot;;
        fclose(in);
        return false;
    }

    //load the palette for 8 bits per pixel
    if(bpp==8) {
    	colours=new RGBQuad[numColours];
    	fread(colours,sizeof(RGBQuad),numColours,in);
    }

    //set up the temporary buffer for the image data
    tempData=new char[dataSize];

    //exit if there is not enough memory
    if(tempData==NULL) {
        error=&quot;Not enough memory to allocate a temporary buffer&quot;;
        fclose(in);
        return false;
    }

    //read in the entire image
    fread(tempData,sizeof(char),dataSize,in);

    //close the file now that we have all the info
    fclose(in);

    //calculate the witdh of the final image in bytes
    byteWidth=padWidth=(int)((float)width*(float)bpp/8.0);

    //adjust the width for padding as necessary
    while(padWidth%4!=0) {
        padWidth++;
    }

    //change format from GBR to RGB
    if(bpp==8) {
    	loaded=convert8(tempData);
   	}
    else if(bpp==24) {
    	loaded=convert24(tempData);
   	}

    //clean up memory
    delete[] tempData;

    //bitmap is now loaded
    error=&quot;Bitmap loaded&quot;;

    //return success
    return loaded;
}
</code></pre>
<p>Das Ergebnis sieht so aus:<br />
<a href="http://up.picr.de/4198297.jpg" rel="nofollow">http://up.picr.de/4198297.jpg</a></p>
<p>Im Original natürlich ohne die komische Huntergrundfarbe sowie mit weiteren schwarzen Linien.</p>
<p>Ich vermute, dass es an der Umwandlung von BGR zu RGB liegt, aber wenn ich die Ausschalte ist in der Ausgabedatei gar nichts mehr <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=":/"
      alt="😕"
    /></p>
<p>Hoffe man kann den Post einigermaßen lesen, ich weiß ist sehr viel <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=":/"
      alt="😕"
    /><br />
Vielen Dank für eure Hilfe <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>Ps: Wenn das hier in n anderes Forum muss, dann bitte verschieben, Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/265354/frage-bezüglich-des-schreibens-einer-bmp-datei-in-datei</link><generator>RSS for Node</generator><lastBuildDate>Fri, 21 Aug 2026 02:40:26 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/265354.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 21 Apr 2010 16:34:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Frage bezüglich des Schreibens einer BMP datei in Datei on Wed, 21 Apr 2010 16:34:20 GMT]]></title><description><![CDATA[<p>Hallo, versuche gerade eine BMP datei via fstream in eine andere Datei zu schreiben. Zwar erzeugt der Code keinen Fehler und IRGENDWAS wird auch in die Datei geschrieben/kopiert, jedoch scheinbar nur Teile. Das Laden in die Bitmapklasse dürfte aufjedenfall funktionieren.</p>
<p>Hiermal der Code, sowie ein Auszug aus der Klasse die zum laden des Bitmaps benutzt wird(nicht von mir):</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
#include &lt;iostream&gt;
#include &quot;Bitmap.h&quot;
using namespace std;

int main () 
{
  Bitmap test(&quot;test.bmp&quot;);
 cout &lt;&lt; endl;
 fstream myfile(&quot;temp.bmp&quot;,ios::out | ios::binary);
 myfile.write((char*)&amp;(test.bmfh),sizeof(BitmapFileHeader));
 myfile.write((char*)&amp;(test.bmih),sizeof(BitmapInfoHeader));
 myfile.write((char*)(test.colours),sizeof(RGBQuad)*256);
 myfile.write(test.data,test.dataSize);

 /*
  // open it for output then write to it
  fstream myfile;
  myfile.open(&quot;test.txt&quot;,ios::out | ios::trunc);

  if (myfile.is_open())   {
     myfile &lt;&lt; &quot;This outputting a line.\n&quot;;
     myfile.close();
  }
 */
 myfile.close();
 getchar();
  return 0;
}
</code></pre>
<pre><code class="language-cpp">//load a bitmap from a file and represent it correctly
//in memory
bool Bitmap::loadBMP(char* file) {
    FILE *in;                  //file stream for reading
    char *tempData;       //temp storage for image data
    int numColours;            //total available colours

    //bitmap is not loaded yet
    loaded=false;
    //make sure memory is not lost
    if(colours!=0) {
        delete[] colours;
    }
    if(data!=0) {
        delete[] data;
    }

    //open the file for reading in binary mode
    in=fopen(file,&quot;rb&quot;);

    //if the file does not exist return in error
    if(in==NULL) {
        error=&quot;File not found&quot;;
        fclose(in);
        return false;
    }

    //read in the entire BITMAPFILEHEADER
    fread(&amp;bmfh,sizeof(BitmapFileHeader),1,in);
	cout &lt;&lt; &quot;sizeof(BitmapFileHeader)=&quot; &lt;&lt; sizeof(BitmapFileHeader) &lt;&lt; endl;
    //check for the magic number that says this is a bitmap
    if(bmfh.bfType!=BITMAP_MAGIC_NUMBER) {
        error=&quot;File is not in DIB format&quot;;
        fclose(in);
        return false;
    }

    //read in the entire BITMAPINFOHEADER
    fread(&amp;bmih,sizeof(BitmapInfoHeader),1,in);
	cout &lt;&lt; &quot;sizeof(BitmapInfoHeader)=&quot; &lt;&lt; sizeof(BitmapInfoHeader) &lt;&lt; endl;

    //save the width, height and bits per pixel for external use
    width=bmih.biWidth;
    height=bmih.biHeight;
    bpp=bmih.biBitCount;
	cout &lt;&lt; &quot;biBitCount      =&quot; &lt;&lt; bmih.biBitCount &lt;&lt; endl;
	cout &lt;&lt; &quot;biClrImportant  =&quot; &lt;&lt; bmih.biClrImportant &lt;&lt; endl;
	cout &lt;&lt; &quot;biClrUsed       =&quot; &lt;&lt; bmih.biClrUsed &lt;&lt; endl;
	cout &lt;&lt; &quot;biCompression   =&quot; &lt;&lt; bmih.biCompression &lt;&lt; endl;
	cout &lt;&lt; &quot;biHeight        =&quot; &lt;&lt; bmih.biHeight &lt;&lt; endl;
	cout &lt;&lt; &quot;biPlanes        =&quot; &lt;&lt; bmih.biPlanes &lt;&lt; endl;
	cout &lt;&lt; &quot;biSize          =&quot; &lt;&lt; bmih.biSize &lt;&lt; endl;
	cout &lt;&lt; &quot;biSizeImage     =&quot; &lt;&lt; bmih.biSizeImage &lt;&lt; endl;
	cout &lt;&lt; &quot;biWidth         =&quot; &lt;&lt; bmih.biWidth &lt;&lt; endl;
	cout &lt;&lt; &quot;biXPelsPerMeter =&quot; &lt;&lt; bmih.biXPelsPerMeter &lt;&lt; endl;
	cout &lt;&lt; &quot;biYPelsPerMeter =&quot; &lt;&lt; bmih.biYPelsPerMeter &lt;&lt; endl;

    //calculate the size of the image data with padding
    dataSize=(width*height*(unsigned int)(bmih.biBitCount/8.0));

    //calculate the number of available colours
    numColours=1&lt;&lt;bmih.biBitCount;
    cout &lt;&lt; numColours &lt;&lt; endl;
    //if the bitmap is not 8 bits per pixel or more
    //return in error
    if(bpp&lt;8) {
        error=&quot;File is not 8 or 24 bits per pixel&quot;;
        fclose(in);
        return false;
    }

    //load the palette for 8 bits per pixel
    if(bpp==8) {
    	colours=new RGBQuad[numColours];
    	fread(colours,sizeof(RGBQuad),numColours,in);
    }

    //set up the temporary buffer for the image data
    tempData=new char[dataSize];

    //exit if there is not enough memory
    if(tempData==NULL) {
        error=&quot;Not enough memory to allocate a temporary buffer&quot;;
        fclose(in);
        return false;
    }

    //read in the entire image
    fread(tempData,sizeof(char),dataSize,in);

    //close the file now that we have all the info
    fclose(in);

    //calculate the witdh of the final image in bytes
    byteWidth=padWidth=(int)((float)width*(float)bpp/8.0);

    //adjust the width for padding as necessary
    while(padWidth%4!=0) {
        padWidth++;
    }

    //change format from GBR to RGB
    if(bpp==8) {
    	loaded=convert8(tempData);
   	}
    else if(bpp==24) {
    	loaded=convert24(tempData);
   	}

    //clean up memory
    delete[] tempData;

    //bitmap is now loaded
    error=&quot;Bitmap loaded&quot;;

    //return success
    return loaded;
}
</code></pre>
<p>Das Ergebnis sieht so aus:<br />
<a href="http://up.picr.de/4198297.jpg" rel="nofollow">http://up.picr.de/4198297.jpg</a></p>
<p>Im Original natürlich ohne die komische Huntergrundfarbe sowie mit weiteren schwarzen Linien.</p>
<p>Ich vermute, dass es an der Umwandlung von BGR zu RGB liegt, aber wenn ich die Ausschalte ist in der Ausgabedatei gar nichts mehr <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=":/"
      alt="😕"
    /></p>
<p>Hoffe man kann den Post einigermaßen lesen, ich weiß ist sehr viel <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=":/"
      alt="😕"
    /><br />
Vielen Dank für eure Hilfe <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>Ps: Wenn das hier in n anderes Forum muss, dann bitte verschieben, Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1886347</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1886347</guid><dc:creator><![CDATA[kingcools]]></dc:creator><pubDate>Wed, 21 Apr 2010 16:34:20 GMT</pubDate></item><item><title><![CDATA[Reply to Frage bezüglich des Schreibens einer BMP datei in Datei on Wed, 21 Apr 2010 17:13:41 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">(char*)&amp;(test.bmfh)
</code></pre>
<p>BitmapFileHeader ist doch ein struct/class, oder? Wie kommst du darauf, dass Der Adressoperator da das richtige macht?<br />
Kannst du denn die Schreib/Leseoperationen nicht in vernünftige Methoden auslagern? Dass man ein Bitmap öffnen und speichern kann?</p>
<pre><code class="language-cpp">class Bitmap {
public:
    void open( const char* file );
    bool write( const char* file );
};
</code></pre>
<p>Dein BitmapFileHeader kann dann z.B. ein writeTo(ostream&amp; stream); bekommen, womit du den Header in einen Stream schreiben kannst. Dann ist nömlich die jeweilige Klasse für ihre eigenen Infos verantwortlich, und nicht am Ende der User selber!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1886360</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1886360</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Wed, 21 Apr 2010 17:13:41 GMT</pubDate></item><item><title><![CDATA[Reply to Frage bezüglich des Schreibens einer BMP datei in Datei on Wed, 21 Apr 2010 17:18:51 GMT]]></title><description><![CDATA[<p>Na klar könnte ich das, aber darum gehts mir ja (zunächst) gar nicht. Ich will erstmal nur den Bitmap in eine anderee Datei schreiben. Wenn das funktioniert, gehts weiter.</p>
<p>Ich hab das so in einer Anleitung gesehen, in der komplexe Datenstrukturen(im Beispiel eine struktur) in eine binarydatei geschrieben wurden und zwar mit dem adressoperator. Ohne gibt es einen Compilerfehler<br />
Ist auch sinniger als ohne?! Die Struktur kann ich ja schlecht zu nem Zeiger auf char umwandeln.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1886364</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1886364</guid><dc:creator><![CDATA[kingcools]]></dc:creator><pubDate>Wed, 21 Apr 2010 17:18:51 GMT</pubDate></item><item><title><![CDATA[Reply to Frage bezüglich des Schreibens einer BMP datei in Datei on Wed, 21 Apr 2010 17:30:22 GMT]]></title><description><![CDATA[<p>Du könntest jetzt bitte die Klassendefinition von (z.B.) BitmapFileHeader posten.<br />
Und nur weil du es so gesehen hast, heißt das nicht dass es bei deiner BitmapFileHeader-Klasse klappt. Es ist eher unwahrscheinlich, dass die Klasse so im Speicher liegt, dass dein Objekt korrekt in einen char* umgewandelt wird, nur durch den cast, so dass der korrekte Bitmap-Header rauskommt!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1886367</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1886367</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Wed, 21 Apr 2010 17:30:22 GMT</pubDate></item><item><title><![CDATA[Reply to Frage bezüglich des Schreibens einer BMP datei in Datei on Wed, 21 Apr 2010 17:33:23 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#ifndef _BITMAP_H
#define _BITMAP_H
//File: Bitmap.h
//Written by:     Mark Bernard
//on GameDev.net: Captain Jester
//e-mail: mark.bernard@rogers.com
//Please feel free to use and abuse this code as much
//as you like.  But, please give me some credit for
//starting you off on the right track.
//
//The file Bitmap.cpp goes along with this file
//
#include &lt;iostream&gt;
#include &lt;cstdio&gt;
#include &lt;string&gt;
using namespace std;

const short BITMAP_MAGIC_NUMBER=19778;
const int RGB_BYTE_SIZE=3;

#pragma pack(push,bitmap_data,1)

typedef struct tagRGBQuad {
	char rgbBlue;
	char rgbGreen;
	char rgbRed;
	char rgbReserved;
} RGBQuad;

typedef struct tagBitmapFileHeader {
	unsigned short bfType;
	unsigned int bfSize;
	unsigned short bfReserved1;
	unsigned short bfReserved2;
	unsigned int bfOffBits;
} BitmapFileHeader;

typedef struct tagBitmapInfoHeader {
	unsigned int biSize;
	int biWidth;
	int biHeight;
	unsigned short biPlanes;
	unsigned short biBitCount;
	unsigned int biCompression;
	unsigned int biSizeImage;
	int biXPelsPerMeter;
	int biYPelsPerMeter;
	unsigned int biClrUsed;
	unsigned int biClrImportant;
} BitmapInfoHeader;

#pragma pack(pop,bitmap_data)

class Bitmap {
public:
    //variables
    RGBQuad *colours;
    char *data;
    bool loaded;
    int width,height;
    unsigned short bpp;
    string error;
    //methods
    Bitmap(void);
    Bitmap(char *);
    ~Bitmap();
    bool loadBMP(char *);
//private:
    //variables
    BitmapFileHeader bmfh;
    BitmapInfoHeader bmih;
    int byteWidth;            //the width in bytes of the image
    int padWidth;             //the width in bytes of the added image
    unsigned int dataSize;                //size of the data in the file
    //methods
    void reset(void);
    bool convert24(char *);		//convert to 24bit RGB bottom up data
    bool convert8(char *);		//convert to 24bit RGB bottom up data
};

#endif //_BITMAP_H
</code></pre>
<p>Woher weiß ich denn, wie ich die Struktur übergeben muss, wenn das nicht immer so geht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1886369</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1886369</guid><dc:creator><![CDATA[kingcools]]></dc:creator><pubDate>Wed, 21 Apr 2010 17:33:23 GMT</pubDate></item><item><title><![CDATA[Reply to Frage bezüglich des Schreibens einer BMP datei in Datei on Thu, 22 Apr 2010 01:58:27 GMT]]></title><description><![CDATA[<p>Hallo, ich hab mir jetzt ne zeitlang den Code des BMP-Laders angeguckt und meine den Fehler gefunden zu haben(bzw. den Fehler in meinem Verständnis des Codes).<br />
Würde aber gerne Bestätigung meiner Vermutung bekommen.<br />
Also ich denke es liegt an der Methode convert8.<br />
Diese sieht wie folgt aus:</p>
<pre><code class="language-cpp">bool Bitmap::convert8(char* tempData) {
	int offset,diff;

	diff=width*height*RGB_BYTE_SIZE;
    //allocate the buffer for the final image data
    data=new char[diff];

    //exit if there is not enough memory
    if(data==NULL) {
        error=&quot;Not enough memory to allocate an image buffer&quot;;
        delete[] data;
        return false;
    }

    if(height&gt;0) {
        offset=padWidth-byteWidth;
        int j=0;
        //count backwards so you start at the front of the image
        for(int i=0;i&lt;dataSize*RGB_BYTE_SIZE;i+=3) {
            //jump over the padding at the start of a new line
            if((i+1)%padWidth==0) {
                i+=offset;
            }
            //transfer the data
            *(data+i)=colours[*(tempData+j)].rgbRed;
            *(data+i+1)=colours[*(tempData+j)].rgbGreen;
            *(data+i+2)=colours[*(tempData+j)].rgbBlue;
            j++;
        }
    }

    //image parser for a forward image
    else {
        offset=padWidth-byteWidth;
        int j=dataSize-1;
        //count backwards so you start at the front of the image
        for(int i=0;i&lt;dataSize*RGB_BYTE_SIZE;i+=3) {
            //jump over the padding at the start of a new line
            if((i+1)%padWidth==0) {
                i+=offset;
            }
            //transfer the data
            *(data+i)=colours[*(tempData+j)].rgbRed;
            *(data+i+1)=colours[*(tempData+j)].rgbGreen;
            *(data+i+2)=colours[*(tempData+j)].rgbBlue;
            j--;
        }
    }

    return true;
}
</code></pre>
<p>In der Schleife wird aus einem ehemaligen Pixel quasi 3 Verschiedene gemacht, jeweils mit dem Rot-,Grün- und Blauanteil.<br />
Dies geschieht hier:</p>
<pre><code class="language-cpp">*(data+i)=colours[*(tempData+j)].rgbRed;
            *(data+i+1)=colours[*(tempData+j)].rgbGreen;
            *(data+i+2)=colours[*(tempData+j)].rgbBlue;
</code></pre>
<p>Dann muss ich natürlich vor dem Speichern in eine andere Datei diese 3 verschiedenen Pixel zu einem einzigen zusammenfügen.<br />
Ist das richtig?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1886503</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1886503</guid><dc:creator><![CDATA[kingcools2]]></dc:creator><pubDate>Thu, 22 Apr 2010 01:58:27 GMT</pubDate></item><item><title><![CDATA[Reply to Frage bezüglich des Schreibens einer BMP datei in Datei on Thu, 22 Apr 2010 02:27:33 GMT]]></title><description><![CDATA[<p>Hallo, Ich bins nochmal.<br />
Also das war in der Tat der Fehler und nachdem ich die inverse Operation dazu ausgeführt hatte ging es.<br />
JEDOCH:<br />
Das Bild erscheint nicht als Symbol in den Windowsordnern, die erscheinen wenn man die Dateien mit großen bzw. kleinen Symbolen anzeigen lässt.<br />
Woran könnte das liegen? Öffnen lässt sich das ganze ohne Probleme und Grafikfehler, nur das Symbol erscheint nicht?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1886505</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1886505</guid><dc:creator><![CDATA[Kingcools2]]></dc:creator><pubDate>Thu, 22 Apr 2010 02:27:33 GMT</pubDate></item><item><title><![CDATA[Reply to Frage bezüglich des Schreibens einer BMP datei in Datei on Thu, 22 Apr 2010 06:06:31 GMT]]></title><description><![CDATA[<p>Vllt. liegt es an einem fehlerhaften BitmapHeader? Entweder erkennt der Windows-Thumbnailer nicht, dass das ein Bitmap sein soll, oder der holt sich den Thumb aus dem Bitmap (embedded Preview). Oder du hast Preview für .bmp deaktiviert <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="😉"
    /><br />
Kannst du nicht mal ein .bmp, bei dem die Vorschau klappt, im Hexeditor anschauen? Und dort mit einem deiner generierten Bitmaps vergleichen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1886519</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1886519</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Thu, 22 Apr 2010 06:06:31 GMT</pubDate></item></channel></rss>