If you want to use pictures in C applications you often need to convert them to an array.
What you need:
- Gimp
- bin2c
Create a new gimp file with your target image size. e.g. 200×200 px
Open the source image, select all, copy. Switch to your created gim file and paste.
Save as bmp. Select your target format in advanced options.
See the following table to find out your target format:
Model | Size | Gimp Property |
---|---|---|
Keil MCB 1700 | 240×320 | R5 G6 B5 |
Now run bin2c on command line:
bin2c -o bitmaps.c image.bmp
1 2 3 4 5 6 7 8 9 10 | /* Generated by bin2c, do not edit manually */ /* Contents of file image.bmp */ const long int image_bmp_size = 69958; const unsigned char image_bmp[69958] = { 0x42, 0x4D, 0x46, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0xB6, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, 0x46, 0x03, 0x05, 0x5B, 0x05, 0x5B, 0x05, 0x5B, 0x42, 0x32, 0x46, 0x03, 0x06, 0xAA, 0xC6, 0xD1, .................... the other 69910 entries .............................. }; |
according to this your bitmaps.h would look like this (but its not generated by bin2c):
1 2 3 4 | #ifndef BITMAPS_H #define BITMAPS_H extern unsigned char image_bmp[]; #endif /* BITMAPS_H */ |
Segger provides a bitmap converter that simplifies this process I guess.