Convert bmp to C array

If you want to use pictures in C applications you often need to convert them to an array.

What you need:

  1. Gimp
  2. 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:

[table id=1 /]

Now run bin2c on command line:

bin2c -o bitmaps.c image.bmp

according to this your bitmaps.h would look like this (but its not generated by bin2c):

Segger provides a bitmap converter that simplifies this process I guess.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.