Working with Embedded Wizard: Generating application specific CLUT

In order to save the graphics memory, many embedded systems operate in the so-called Index8 color format. With this format the system stores the pixel very compact as small unsigned 8-bit values. During the screen refresh the graphics hardware uses the 8-bit values to pick from a global color look-up table (CLUT) the corresponding colors, which then are displayed on the screen.

The CLUT itself stores its entries usually as true color values, e.g. in 32-bit RGBA8888 or 16-bit RGB565 format. A GUI application running on such graphics hardware can thus benefit from the large color space while, at the same time, it occupies less graphics memory. The following figure demonstrates the principle function of the color look-up table:

Disadvantage of this technique is that with 8-bit values the addressing into the CLUT is limited to 256 entries. In other words, when using the Index8 color format the GUI application can display maximally 256 different colors at once, no more. To make your GUI application look as good as possibly it is thus essential to compose the CLUT in advance from well selected colors.

The challenging part lies in finding the optimal choice of colors for your specific user interface. The classical way to build a CLUT is to compose a representative collage of UI elements in Adobe Photoshop (or any other suitable graphics application) to create a color palette. This is not easy especially if your application is using transparencies, which result in a huge variety mix colors.

Therefore Embedded Wizard Studio provides a feature to automatically generate the best possible CLUT from the screen contents your application displays at its runtime. The following screenshots demonstrate the difference in the appearance of a GUI component in a project using a non-optimized and an optimized CLUT:

If you don't use this feature, Embedded Wizard falls back on the default (non-optimized) CLUT containing 256 diverse colors like black, red, green, blue, yellow, etc. The default CLUT is ideal when you start with the development for a target system using Index8 as color format. In this manner you are able to see something on the screen. In practice, however, to get the best possible results on the screen you should generate a CLUT optimized for your particular application. How you achieve this, is addressed in the sections below.

Please note, this chapter is addressed to users, which use a Platform Package for the Index8 color format. If your project is configured to use another color formats (e.g. LumA44 or RGB565, etc.) you can ignore this chapter.

Collect colors used in the application

In the first step Embedded Wizard collects all used colors. You start this operation by selecting in the menu Build the command Start Prototyper with color statistic .... Thereupon the Prototyper window appears and you can play with your application or component as usual. During this time the Embedded Wizard counts all colors displayed on the screen. Once you are finished you close the Prototyper again, which causes the collected information being stored in a color statistic file.

You can build up your color statistics progressively. If you want to generate a CLUT file in an early stage of developing an UI application, you can create a statistic file and incrementally update it in later Prototyper sessions.

Generate the CLUT file

After you are finished with the above described color collection you select in the menu Build the command Generate CLUT file .... Activating this command causes the Generate CLUT dialog to appear where you can configure and start the CLUT generation. In particular in the dialog you can select the desired strategy to generate the CLUT and, if necessary, preallocate CLUT entries for other applications co-existing in your device. The CLUT generation uses the statistic information collected in the preceding step.

Use the CLUT file

The generated CLUT is stored per default in the file Clut.txt directly within your project folder. In order to use this CLUT in your project you have to select the file explicitly in the attribute Clut of the profile you have configured to use an Index8 Platform Package. The CLUT file itself is an ordinary text file you can open in a text editor and review it if desired.

Once the CLUT file is selected, the Composer as well as the Prototyper window will use the colors stored there. Similarly when you generate code for a profile with an associated CLUT file, the color information is taken over. During the prototyping and code generation Embedded Wizard tries to map the colors of bitmaps and drawn graphical objects to the optimal entries within the CLUT.

Please note, the attribute Clut is available for profiles configured to use an Index8 Platform Package only. If your profile doesn't expose such attribute, then review its attribute PlatformPackage.

You can repeat the above described steps as desired. Usually you do this after adding new bitmaps and components to your project. Finally, the CLUT should reflect the actual content of your application. If you add to your project a new bitmap containing blue colors and in the past your entire application was using nuances of the red color only, then you can imagine that without updating the CLUT the blue color will not appear as expected.