BMP-Datei in ein c-Array wandeln

Gast #16344
Hallo Reinhold!

Am einfachsten wirds wohl sein, wenn du deine BMP-Files in ein 
RAW-Datenformat umwandelst und dann ein kleines Tool schreibst, welches 
daraus ein Text-File mit dem C-Array generiert... mir ist nicht bekannt, 
ob es so ein Tool eventuell schon gibt...

wenns wirklich BMP sein soll, hier das Datenformat:

--------I-BMP-------------------------------
The BMP files are the way, Windows stores bit mapped images. The BMP 
image
data is bit packed but every line must end on a dword boundary - if 
thats not
the case, it must be padded with zeroes. BMP files are stored bottom-up,
that means that the first scan line is the bottom line. The BMP format 
has four
incarnations, two under Windows (new and old) and two under OS/2, all 
are
described here.
OFFSET              Count TYPE   Description
0000h                   2 char   ID='BM' - BitMap
                                 OS/2 also supports the following IDs :
                                 ID='BA' - Bitmap Array
                                 ID='CI' - Color Icon
                                 ID='CP' - Color Pointer (mouse cursor)
                                 ID='IC' - Icon
                                 ID='PT' - Pointer (mouse cursor)
0002h                   1 dword  Filesize of whole file
0006h                   4 byte   reserved
000Ah                   1 dword  Offset of bitmap in file
                                 ="BOF"
000Eh                   1 dword  Length of BitMapInfoHeader
                                 The BitMapInfoHeader starts directly 
after
                                 this header.
                                 12 - OS/2 1.x format
                                 40 - Windows 3.x format
                                 64 - OS/2 2.x format
0012h                   1 dword  Horizontal width of bitmap in pixels
0016h                   1 dword  Vertical width of bitmap in pixels
001Ah                   1 word   Number of planes
001Ch                   1 word   Bits per pixel ( thus the number of 
colors )
                                 ="BPP"
001Eh                   1 dword  Compression type, see ALGRTHMS.txt for 
descrip-
                                 tion of the different types
                                 0 - none
                                 1 - RLE 8-bit/Pixel
                                 2 - RLE 4-bit/Pixel
0022h                   1 dword  Size of picture in bytes
0026h                   1 dword  Horizontal resolution
002Ah                   1 dword  Vertical resolution
002Ah                   1 dword  Number of used colors
002Ah                   1 dword  Number of important colors
0036h                   ? rec    Definition of N colors
                                 N=1 shl "BPP"
                        1 byte   Blue component
                        1 byte   Green component
                        1 byte   Red component
                        1 byte   Filler
"BOF"                   ? byte   Image data

(Imaga Data ist soweit ich weiß immer RGBRGBRGBRGB...)

ciao Christian

Antwort schreiben

Eine eigene Frage? Dieser Thread ist über 24 Jahre alt. Stell sie in einem eigenen Thread – dort lesen mehr Leute mit, und sie wird öfter und schneller beantwortet.

Neuen Thread starten

Eine Lösung, Ergänzung oder Rückmeldung zu diesem Thread? Dann antworte hier.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.