emWin upgrade     Trade-In program     Web shop

emWin Bitmap Converter

The Bitmap Converter is designed for converting common image file formats like BMP, PNG or GIF into the desired emWin bitmap format. That can be a C file which can directly be compiled and linked with the project or a binary format, which can be loaded at runtime. Simply load an image into the application. Convert the color format if you want or have to, and save it in the appropriate format.

Screenshot of the Bitmap Converter

What it does

The Bitmap Converter is primarily intended as a tool to convert bitmaps from a PC format to a C file. Bitmaps which can be used with emWin are normally defined as GUI_BITMAP structures in C. The structures - or rather the picture data which is referenced by these structures - can be quite large. It is time-consuming and inefficient to generate these bitmaps manually. We therefore recommend using the Bitmap Converter, which automatically generates C files from bitmaps.
An other useful feature is the ability to save images as C stream files. The advantage against a normal C file is, that these data streams can be located anywhere on any media whereas C files need to be located in the addressable CPU area.
It also features color conversion, so that the resulting C code is not unnecessarily large. You would typically reduce the number of bits per pixel in order to reduce memory consumption. The Bitmap Converter displays the converted image.
A number of simple functions can be performed with the Bitmap Converter, including scaling the size, flipping the bitmap horizontally or vertically, rotating it, and inverting the bitmap indices or colors (these features can be found under the Image menu). Any further modifications to an image must be made in a bitmap manipulation program such as Adobe Photoshop or Corel Photopaint. It usually makes the most sense to perform any image modifications in such a program, using the Bitmap Converter for converting purposes only.

Loading a bitmap

Supported input file formats

The Bitmap Converter basically supports Windows bitmap files (*.bmp), "Graphic Interchange Format" (*.gif) and "Portable Network Graphics" (*.png):

Windows Bitmap Files (BMP)

The Bitmap Converter supports the most common bitmap file formats. Bitmap files of the following formats can be opened by the Bitmap Converter:

  • 1, 4 or 8 bits per pixel (bpp) with palette;
  • 16, 24 or 32 bpp without palette (full-color mode, in which each color is assigned an RGB value);
  • RLE4 and RLE8.

Trying to read bitmap files of other formats will cause an error message of the Bitmap Converter.

Graphic Interchange Format (GIF)

The Bitmap Converter supports reading GIF files. For general editing only the first image of the GIF file is used. GIF image consisting of several images may be converted to animated sprites and animated cursors.
Transparency and interlaced GIF images are supported by the converter.

Portable Network Graphic (PNG)

The PNG format is the most recommended format to create images with alpha blending. The Bitmap Converter supports reading PNG images with alpha channel.

Loading from a file

An image file of one of the supported formats may be opened directly in the Bitmap Converter by selecting File/Open.

Using the clipboard

Any other type of bitmap (that is, .jpg, .jpeg, .tif) may be opened with another program, copied to the clipboard, and pasted into the Bitmap Converter. This process will achieve the same effect as loading directly from a file.

Color conversion

The primary reason for converting the color format of a bitmap is to reduce memory consumption. The most common way of doing this is by using the option Best palette as in the above example, which customizes the palette of a particular bitmap to include only the colors which are used in the image. It is especially useful with full-color bitmaps in order to make the palette as small as possible while still fully supporting the image. Once a bitmap file has been opened in the Bitmap Converter, simply select Image/Convert Into/Best palette from the menu. If it is necessary to keep transparency select Image/Convert Into/Best palette + transparency.
For certain applications, it may be more efficient to use a fixed color palette, chosen from the menu under Image/Convert Into. For example, suppose a bitmap in full-color mode is to be shown on a display which supports only four grayscales. It would be a waste of memory to keep the image in the original format, since it would only appear as four grayscales on the display. The full-color bitmap can be converted into a four-grayscale, 2bpp bitmap for maximum efficiency.
The procedure for conversion would be as follows:

The Bitmap Converter is opened and the same file is loaded as in steps 1 and 2 of the previous example.

The Bitmap Converter displays the loaded bitmap.

Choose "Image" -> "Convert Into" -> "Gray"

Choose "Image" -> "Convert Into" -> "Gray4".

The Bitmap Converter displays the converted bitmap.

In this example, the image uses less memory since a palette of only 4 grayscales is used instead of the full-color mode. If the target display supports only 4 grayscales, there is no use in having a higher pixel depth as it would only waste memory.


Dithering is a method for showing more details on systems with only a few available colors than with a simple color conversion. It gives the illusion of a better color depth by using noise to randomize quantization error. If for example a photo needs to be drawn on a b/w system normally not much details would be visible after a simple conversion. However, dithering is able to show much more details:

Original black / white black / white, dithered

The above table shows clearly the difference between dithering and a simple conversion. To dither a picture the command Image/Dither to/... should be used:

Using a custom palette

Converting bitmaps to a custom palette and saving them without palette information can save memory and can increase the performance of bitmap drawing operations.

More efficient memory utilization

Per default each bitmap contains its own palette. Even the smallest bitmaps can contain a large palette with up to 256 colors. In many cases only a small fraction of the palette is used by the bitmap. If using many of these bitmaps the amount of memory used by the palettes can grow rapidly.
So it can save much ROM if converting the bitmaps used by emWin to the available hardware palette and saving them as (D)evice (D)ependent (B)itmaps without palette information.

Better bitmap drawing performance

Before emWin draws a bitmap, it needs to convert each device independent bitmap palette to the available hardware palette. This is required because the pixel indices of the bitmap file are indices into the device independent bitmap palette and not to the available hardware palette.
Converting the bitmap to a DDB means that color conversion at run time is not required and speeds up the drawing.

Saving a palette file

The Bitmap Converter can save the palette of the currently loaded bitmap into a palette file which can be used for converting other bitmaps with the command Image/Convert Into/Custom palette. This requires that the current file is a palette based file and not a RGB file. To save the palette the command File/Save palette... can be used.

Palette file format

Custom palette files are simple files defining the available colors for conversion. They contain the following:

  • Header (8 bytes)
  • NumColors (U32, 4 bytes)
  • 0 (4 bytes)
  • U32 Colors[NumColors] (NumColors*4 bytes, type GUI_COLOR)

Total file size is therefore: 16 + (NumColors * 4) bytes. A custom palette file with 8 colors would be 16 + (8 * 4) = 48 bytes. At this point, a binary editor must be used in order to create such a file.
The maximum number of colors supported is 256; the minimum is 2.


This example file would define a palette containing 2 colors -- red and white:

0000: 65 6d 57 69 6e 50 61 6c 02 00 00 00 00 00 00 00
0010: ff 00 00 00 ff ff ff 00

The 8 headers make up the first eight bytes of the first line. The U32 is stored lsb first (big endian) and represents the next four bytes, followed by the four 0 bytes. Colors are stored 1 byte per color, where the 4th byte is 0 as follows: RRGGBB00. The second line of code defines the two colors used in this example.

Palette files for fixed palette modes

Using the custom palette feature can even make sense with the most common used fixed palette modes, not only with custom hardware palettes. For the most palette based fixed palette modes a palette file can be found in the folder Sample\Palette.

Converting a bitmap

The command Image/Convert Into/Custom palette should be used for converting the currently loaded bitmap to a custom palette. The Bitmap Converter tries to find the nearest color of the palette file for each pixel of the currently loaded bitmap.

Generating C files from bitmaps

The main function of the Bitmap Converter is to convert PC-formatted bitmaps into C files which can be used by emWin. Before doing so, however, it is often desirable to modify the color palette of an image so that the generated C file is not excessively large.

The bitmap may be saved as a bmp or a gif file (which can be reloaded and used or loaded into other bitmap manipulation programs) or as a C file. A C file will serve as an input file for your C compiler. It may contain a palette (device-independent bitmap, or DIB) or be saved without (device-dependent bitmap, or DDB). DIBs are recommended, as they will display correctly on any display; a DDB will only display correctly on a display which uses the same palette as the bitmap.
C files may be generated as "C with palette", "C without palette", "C with palette, compressed" or "C without palette, compressed". For more information on compressed files, see the section "Compressed bitmaps" as well as the example at the end of the chapter.

Supported bitmap formats

The following table shows the currently available output formats for C files:

Format Color depth Compression Transparency Palette
1 bit per pixel 1bpp no yes yes
2 bits per pixel 2bpp no yes yes
4 bits per pixel 4bpp no yes yes
8 bits per pixel 8bpp no yes yes
Compressed, RLE4 4bpp yes yes yes
Compressed, RLE8 8bpp yes yes yes
12 bits per pixel 444_12 12bpp no no no
12 bits per pixel M444_12, red and blue swapped 12bpp no no no
12 bits per pixel 444_12_1 12bpp no no no
12 bits per pixel M444_12_1, red and blue swapped 12bpp no no no
12 bits per pixel 444_16 12bpp no no no
12 bits per pixel M444_16, red and blue swapped 12bpp no no no
High color 555 15bpp no no no
High color 555, red and blue swapped 15bpp no no no
High color 565 16bpp no no no
High color 565, red and blue swapped 16bpp no no no
High color 565, compressed 16bpp yes no no
High color 565, red and blue swapped, compressed 16bpp yes no no
High color A555 with alpha channel 15bpp no yes no
High color AM555 with alpha channel, red and blue swapped 15bpp no yes no
High color A565 with alpha channel 16bpp no yes no
High color AM565 with alpha channel, red and blue swapped 16bpp no yes no
True color 888 24bpp no no no
True color 8888 with alpha channel 32bpp no yes no
True color 8888 with alpha channel, compressed 32bpp yes yes no
Alpha channel, compressed 8bpp yes yes no

Palette information

A bitmap palette is an array of 24 bit RGB color entries. Bitmaps with a color depth from 1 - 8 bpp can be saved with (device independent bitmap, DIB) or without palette information (device dependent bitmap DDB).

Device independent bitmaps (DIB)

The color information is stored in the form of an index into the color array. Before emWin draws a DIB, it converts the 24 bit RGB colors of the bitmap palette into color indices of the hardware palette. The advantage of using DIBs is that they are hardware independent and can be drawn correctly on systems with different color configurations. The disadvantages are the additional ROM requirement for the palette and the slower performance because of the color conversion.

Device dependent bitmaps (DDB)

The pixel information of a DDB is the index of the displays hardware palette. No conversion needs to be done before drawing a DDB. The advantages are less ROM requirement and a better performance. The disadvantage is that these bitmaps can not be displayed correctly on systems with other color configurations.


A palette based bitmap can be converted to a transparent bitmap. Transparency means each pixel with index 0 will not produce any output. The command Image/Transparency can be used to select the color which should be used for transparency. After selecting the transparent color, the pixel indices of the image will be recalculated, so that the selected color is on position 0 of the bitmap palette. When saving the bitmap file as C file, it will be saved with the transparency attribute.

Alpha blending

Alpha blending is a method of combining an image with the background to create the effect of semi transparency. The alpha value of a pixel determines its transparency. The color of a pixel after drawing the bitmap is a blend of the former color and the color value in the bitmap. In emWin, logical colors are handled as 32 bit values. The lower 24 bits are used for the color information and the upper 8 bits are used to manage the alpha value. An alpha value of 0 means the image is opaque and a value of 0xFF means completely transparent. Whereas BMP and GIF files do not support alpha blending PNG files support alpha blending. So the easiest way to create bitmap files with alpha blending is to load a PNG file. When working with BMP and/or GIF files the Bitmap Converter initially has no information about the alpha values.

Loading a PNG file

This is the most recommended way for creating bitmaps with an alpha mask:

The PNG file contains all required information.

Loading the alpha values from an alpha mask bitmap

This method loads the alpha values from a separate file. Black pixels of the alpha mask file means opaque and white means transparent. The following table shows an example:

Starting point Alpha mask Result

The command File/Load Alpha Mask can be used for loading an alpha mask.

Creating the alpha values from two bitmaps

This method uses the difference between the pixels of two pictures to calculate the alpha values. The first image should show the item on a black background. The second image should show the same on a white background. The following table shows an example of how to create the alpha values using the command File/Create Alpha:

Starting point Black background White background Result

The command File/Create Alpha can be used tor creating the alpha values.

Selecting the best format

emWin supports various formats for the generated C file. It depends on several conditions which will be the ’best’ format and there is no general rule to be used. Color depth, compression, palette and transparency affect the drawing performance and/or ROM requirement of the bitmap.

Color depth

In general the lower the color depth the smaller the ROM requirement of the bitmap. Each display driver has been optimized for drawing 1bpp bitmaps (text) and bitmaps with the same color depth as the display.


The supported RLE compression method has the best effect on bitmaps with many horizontal sequences of equal-colored pixels. Details later in this chapter. The performance is typically slightly slower than drawing uncompressed bitmaps.


The ROM requirement of a palette is 4 bytes for each color. So a palette of 256 colors uses 1 Kbyte. Furthermore emWin needs to convert the colors of the palette before drawing the bitmap. Advantage: Bitmaps are device independent meaning they can be displayed on any display, independent of its color depth and format.


The ROM requirement of transparent bitmaps is the same as without transparency. The performance is with transparency slightly slower than without.

High color and true color bitmaps

Special consideration is required for bitmaps in these formats. Generally the use of these formats only make sense on displays with a color depth of 15 bits and above. Further it is strongly recommended to save the C files in the exact same format used by the hardware. Note that using the right format will have a positive effect on the drawing performance. If a high color bitmap for example should be shown on a system with a color depth of 16bpp which has the red and blue components swapped, the best format is ’High color 565, red and blue swapped’. Already a slightly other format has the effect, that each pixel needs color conversion, whereas a bitmap in the right format can be rendered very fast without color conversion. The difference of drawing performance in this case can be factor 10 and more.

Saving the file

The basic procedure for using the Bitmap Converter is illustrated below:

Step 1: Start the application.

The Bitmap Converter is opened showing an empty window.

Step 2: Load a bitmap into the Bitmap Converter.

Choose File/Open.
Locate the document you want to open and click Open. The Bitmap Converter can open images of the bmp, gif, png and sbmp format.

The Bitmap Converter displays the loaded bitmap.

Choose Image/Convert Into.
Select the desired palette.
In this example, the option Best palette is chosen.
The Bitmap Converter displays the converted bitmap.

The image is unchanged in terms of appearance, but uses less memory since a palette of only 15 colors is used instead of the full-color mode. These 15 colors are the only ones actually required to display this particular image.

Step 4: Save the bitmap as a C file.

Choose File/Save As.
Select a destination and a name for the C file.
Select the file type. In this example, the file is saved as C bitmap file.
Click Save.

Step 5: Specify bitmap format.

If the bitmap should be saved as C file the format should now be specified. Use one of the available formats shown in the dialog. If the bitmap should be saved without palette, activate the check box "Without palette".

The Bitmap Converter will create a separate file in the specified destination, containing the C source code for the bitmap.

Generating C stream files

A C stream file consists of the same information as a C file. Contrary to a C file a data stream can be located anywhere and does not need to be compiled or linked with the project. All supported output formats described for C files are also available for C stream files. emWin supports creating bitmaps from data streams and drawing data streams directly. Detailed information about C stream file support can be found under “Drawing bitmaps” on page 119.

Compressed bitmaps

The Bitmap Converter and emWin support run-length encoding (RLE) compression of bitmaps in the resulting source code files. The RLE compression method works most efficiently if your bitmap contains many horizontal sequences of equal-colored pixels. An efficiently compressed bitmap will save a significant amount of space. However, compression is not recommended for photographic images since they do not normally have sequences of identical pixels. It should also be noted that a compressed image may take slightly longer to display.

Storing a bitmap using RLE compression can be done by selecting one of the compressed output formats when saving as a C file: "C with palette, compressed" or "C without palette, compressed". There are no special functions needed for displaying compressed bitmaps; it works in the same way as displaying uncompressed bitmaps.

Compression ratios

The ratio of compression achieved will vary depending on the bitmap used. The more horizontal uniformity in the image, the better the ratio will be. A higher number of bits per pixel will also result in a higher degree of compression.
In the bitmap used in the previous examples, the total number of pixels in the image is (200*94) = 18,800.
Since 2 pixels are stored in 1 byte, the total uncompressed size of the image is 18,800/2 = 9,400 bytes.
The total compressed size for this particular bitmap is 3,803 bytes for 18,800 pixels.
The ratio of compression can therefore be calculated as 9,400/3,803 = 2.47.

Creating animated sprites / cursors

The Bitmap Converter can be used to convert animated GIF files to animated sprites / cursors in C file format. This functionality is offered by the entries in the file menu which are shown below:

After clicking one of the according file menu entries, a file dialog appears and an animated GIF file can be chosen. Once this is done the name of the resulting C file needs to be specified. Converting animated GIF files to animated sprites / cursors does not require any further parameters. The process is performed automatically. Since the effort depends on the input GIF file, completing this task may take a moment. The Bitmap Converter can be used again as soon as the mouse cursor is changed to the simple arrow again.

Animated Sprite example

The following shows the structure of an animated sprite C file as it is generated by the Bitmap Converter. Although animations consist of several images, the palette and pixel data structures are shown only once here. Variable data is described using place holders.

File header

*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                           www.segger.com                           *
*                                                                    *
* C-file generated by                                                *
*                                                                    *
*        Bitmap Converter for emWin %_VERSION_%.                     *
*        Compiled %_COMPILE_DATE_%                                   *
*        (C) 1998 - 2015 Segger Microcontroller GmbH & Co. KG        *
*                                                                    *
*                                                                    *
* Source file: %_FILENAME_%.gif (Animated Sprite)                    *
* Dimensions:  %_X_SIZE_% * %_Y_SIZE_%                               *
* NumImages:   %_NUMBER_OF_IMAGES_%                                  *
* Duration:    %_OVERALL_DURATION_%                                  *
*                                                                    *

#include <stdlib.h>

#include "GUI.h"

  #define GUI_CONST_STORAGE const

Palette and pixel data


  %_NUMBER_OF_COLORS_%,   // Number of entries
%_TRANSPARENCY_FLAG_%,  // No transparency

static GUI_CONST_STORAGE unsigned char _ac%_FILENAME_%%_INDEX_%[] = {

General data

  { %_X_SIZE_%,                %_Y_SIZE_%,
    %_BYTES_PER_LINE_%,        %_BITS_PER_PIXEL_%,
    _ac%_FILENAME_%%_INDEX_%,  &_Pal%_FILENAME_%%_INDEX_%

const GUI_BITMAP * apbm%_FILENAME_%[] = {

const unsigned aDelay%_FILENAME_%[] = {

/*************************** End of file ****************************/

Animated Cursor example

The file structure for animated cursors almost equals the structure for animated sprites. Therefor only the differences are mentioned here.
The array of bitmap pointers is defined as static:

static const GUI_BITMAP * _apbm%_FILENAME_%[] = {

The array of delays is defined as static:

static const unsigned _aDelay%_FILENAME_%[] = {

A non-static definition of a GUI_CURSOR_ANIM structure is placed at the end:

const GUI_CURSOR_ANIM Cursor%_FILENAME_% = {
  _apbm%_FILENAME_%,    // Pointer to an array of bitmaps
  0,                    // x coordinate of the hot spot
  0,                    // y coordinate of the hot spot
  0,                    // Period, should be 0 here
  _aDelay%_FILENAME_%,  // Pointer to an array of periods
  %_NUMBER_OF_IMAGES_%  // Number of images

Additional information

The hot spot coordinate define the position which is recognized by emWin when PID events occur. If the hot spot should not be represented by the topmost leftmost pixel, the according values in the GUI_CURSOR_ANIM structure may be modified.
The array of delays is always created. In case every image uses the same delay, the forth value in the GUI_CURSOR_ANIM structure may be set accordingly. In this case the array of delays may be deleted after the fifth value of the GUI_CURSOR_ANIM structure was set to NULL.

Command line usage

It is also possible to work with the Bitmap Converter using the command prompt. All conversion functions available in the Bitmap Converter menu are available as commands, and any number of functions may be performed on a bitmap in one command line.

Format for commands

Commands are entered using the following format:

BmpCvt <filename>.bmp <-command>

If more than one command is used, one space is typed between each. For example, a bitmap with the name logo.bmp is converted into Best palette format and saved as a C file named logo.bmp all at once by entering the following at the command prompt:

BmpCvt logo.bmp -convertintobestpalette -saveaslogo,1 -exit

Note that while the file to be loaded into the Bitmap Converter always includes its bmp extension, no file extension is written in the -saveas command. An integer is used instead to specify the desired file type. The number 1 in the -saveas command above designates "C with palette". The -exit command automatically closes the program upon completion. See the table below for more information.

Command line options

The following table lists all permitted Bitmap Converter commands. It can also be viewed at any time by entering BmpCvt -? at the command prompt.

Command Description
-convertintobw Convert to BW.
-convertintogray4 Convert to Gray4.
-convertintogray16 Convert to Gray16.
-convertintogray64 Convert to Gray64.
-convertintogray256 Convert to Gray256.
-convertinto111 Convert to 111.
-convertinto222 Convert to 222.
-convertinto233 Convert to 233.
-convertinto323 Convert to 323.
-convertinto332 Convert to 332.
-convertinto8666 Convert to 8666.
-convertintorgb Convert to RGB.
-convertintobestpalette Convert to best palette.
-convertintotranspalette Convert to best palette with transparency.
-convertintocustompalette<filename> Convert to a custom palette.
<filename> User-specified filename of desired custom palette.
-exit Terminate PC program automatically.
-fliph Flip image horizontally.
-flipv Flip image vertically.
-help Display this box.
-invertindices Invert indices.
-invertpalette Invert palette entries.
-rotate90cw Rotate image by 90 degrees clockwise.
-rotate90ccw Rotate image by 90 degrees counterclockwise.
-rotate180 Rotate image by 180 degrees.
-saveas<filename>,<type>[,<fmt>[,<noplt>]] Save file as filename.
  <filename> User-specified file name including the file extension.
  <type> Must be an integer from 1 to 4 as follows:
1: C with palette (.c file)
2: Windows Bitmap file (bmp file)
3: C stream (.dta file)
4: GIF format (gif file)
  <fmt> Specifies the bitmap format (only if type == 1):
1: 1 bit per pixel*
2: 2 bits per pixel*
4: 4 bits per pixel*
5: 8 bits per pixel*
6: RLE4 compression*
7: RLE8 compression*
8: High color 565
9: High color 565, red and blue swapped
10: High color 555
11: High color 555, red and blue swapped
12: RLE16 compression
13: RLE16 compression, red and blue swapped
15: True color 32bpp, compressed
16: True color 32bpp
17: True color 24bpp
18: Alpha channel 8bpp, compressed
19: 16bpp (444_12)
20: 16bpp (444_12), RB swapped
21: 16bpp (444_12_1)
22: 16bpp (444_12_1), RB swapped
23: 16bpp (444_16)
24: 16bpp (444_16), RB swapped
25: High color (A555) with alpha channel
26: High color (AM555) with alpha channel, red and blue swapped
27: High color (A565) with alpha channel
28: High color (AM565) with alpha channel, red and blue swapped

If this parameter is not given, the Bitmap Converter uses the following
default formats in dependence of the number of colors of the bitmap:
Number of colors <= 2: 1 bit per pixel
Number of colors <= 4: 2 bits per pixel
Number of colors <= 16: 4 bits per pixel
Number of colors <= 256: 8 bits per pixel
RGB: High color 565
  <noplt> Saves the bitmap with or without palette (only if type == 1)
0: Save bitmap with palette (default)
1: Save bitmap without palette
-transparency<RGB-Color> Sets the transparent color.
  <RGB-Color> RGB color which should be used as transparent color.
-? Displays the command line table.

* Images need to be converted to an according format before they can be stored in a format of 8 or less bpp.

Example of a converted bitmap

A typical example for the use of the Bitmap Converter would be the conversion of your company logo into a C bitmap. Take another look at the example bitmap picture below:

The bitmap is loaded into the Bitmap Converter, converted to Best palette, and saved as "C with palette". The resulting C source code is displayed below (some data is not shown to conserve space).

Resulting C code (generated by the Bitmap Converter)

*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                                                                    *
*        Internet: www.segger.com    Support:  support@segger.com    *
*                                                                    *
* Source file: SeggerLogo200
* Dimensions:  200 * 100
* NumColors:   33

#include <stdlib.h>

#include "GUI.h"

  #define GUI_CONST_STORAGE const

static GUI_CONST_STORAGE GUI_COLOR ColorsSeggerLogo200[] = {

  33,    /* number of entries */
  0,     /* No transparency */

static GUI_CONST_STORAGE unsigned char acSeggerLogo200[] = {
  0x00, 0x00,       /* Not all data is shown in this example */
  0x00, 0x92,
  0xC6, 0x22,
  0x0A, 0x22

extern GUI_CONST_STORAGE GUI_BITMAP bmSeggerLogo200;

  200, /* XSize */
  100, /* YSize */
  200, /* BytesPerLine */
  8, /* BitsPerPixel */
  acSeggerLogo200,  /* Pointer to picture data (indices) */
  &PalSeggerLogo200  /* Pointer to palette */

/*************************** End of file ****************************/

Compressing the file

We can use the same bitmap image to create a compressed C file, which is done simply by loading and converting the bitmap as before, and saving it as "C with palette, compressed". The source code is displayed below (some data is not shown to conserve space).

The compressed image size can be seen towards the end of the file as 3,730 bytes for 18,800 pixels.

Resulting compressed C code (generated by the Bitmap Converter)

*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                                                                    *
*        Internet: www.segger.com    Support:  support@segger.com    *
*                                                                    *
* Source file: SeggerLogo200_comp
* Dimensions:  200 * 100
* NumColors:   33

#include <stdlib.h>

#include "GUI.h"

  #define GUI_CONST_STORAGE const

static GUI_CONST_STORAGE GUI_COLOR ColorsSeggerLogo200_comp[] = {
  0xFFFFFF, 0x353537, 0x9C4B37, 0xCDCDCD,

static GUI_CONST_STORAGE GUI_LOGPALETTE PalSeggerLogo200_comp = {
  33,    /* number of entries */
  0,     /* No transparency */

static GUI_CONST_STORAGE unsigned char acSeggerLogo200_comp[] = {
  /* RLE: 006 Pixels @ 000,000*/ 6, 0x00,
  /* RLE: 188 Pixels @ 006,000*/ 188, 0x01,
  /* RLE: 188 Pixels @ 006,099*/ 188, 0x01,
  /* RLE: 006 Pixels @ 194,099*/ 6, 0x00,
};  /* 3730 for 20000 pixels */

extern GUI_CONST_STORAGE GUI_BITMAP bmSeggerLogo200_comp;

GUI_CONST_STORAGE GUI_BITMAP bmSeggerLogo200_comp = {
  200, /* XSize */
  100, /* YSize */
  200, /* BytesPerLine */
  GUI_COMPRESS_RLE8, /* BitsPerPixel */
  acSeggerLogo200_comp,  /* Pointer to picture data (indices) */
  &PalSeggerLogo200_comp  /* Pointer to palette */

/*************************** End of file ****************************/