Forum: Mikrocontroller und Digitale Elektronik BMP-Datei in ein c-Array wandeln


von Rein (Gast)


Lesenswert?

Hallo allerseits,
kann mir jemand helfen, wie man ein BMP-Datei in ein C-Array umwandelt, 
damit ich das dann auf meinem LCD ausgeben kann?
Danke an alle.
Reinhold

von hammer_c (Gast)


Lesenswert?

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

von mikki merten (Gast)


Lesenswert?

Hier findest du die benötigten Informationen für diverse Bitmap 
Dateiformate:
http://www.dcs.ed.ac.uk/home/mxr/gfx/2d-hi.html

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.