Converting Images to Use a Common Palette in GIMP

Microchip Graphics Library

Microchip Graphics Library
Converting Images to Use a Common Palette in GIMP

INTRODUCTION 

Some controllers have predefined palettes associated with them. The palette’s colors can not be altered. When converting images, it is desired to have the images use the controller’s predefined color palette. For example, a controller may have a grayscale palette of 16 colors. An image may use a palette of 16 grayscale colors, but the palette may define grayscale colors that are not the same as the controller’s palette. By using the GNU Image Manipulation Program, GIMP, images can be converted using a palette matching the grayscale colors of the controller. After converting the image to use this palette, it can be converted by the Graphics Resource Converter, GRC, to be used by Microchip’s Graphics Library. 

 

DOWNLOADS 

The following are helpful websites for downloaded the tools and firmware needed:

  • GIMP 2.6 – GNU Image Manipulation Program (www.gimp.org)
  • Graphics Library – This library is part of the Microchip Application Libraries (www.microchip.com/mla)
 

CONVERTING AN IMAGE 

Follow these steps to convert an image to use a predefined color palette (for this example, the palette used has 16 grayscale colors):

  1. Open the GIMP application.
  2. Load the image. FILE->Open
    • If the image is not a Bitmap, you will need to save it as one.
      1. FILE-Save as…
      2. Choose the Select File Type (By Extension)
 

 

  1. Select Windows BMP Image
 

 

  1. Select Save
  2. Select Save under the Save as BMP dialog
 

 

  1. Select WINDOWS->Dockable Dialogs->Palettes
 

 

  • The Palette Dialog will appear.
 

 

  1. In the Palette Dialog Select Import Palette. This can be done by a right click on any of the Palettes on the Palette Dialog.
 

 

  • The Import Palette Dialog will appear.
 

 

  1. Select the Palette file radio button.
    • Select the palette file .gpl (For example: Grayscale-Palette-4bpp.gpl) (see image in Step 4).
  2. Select the Import button.
    • The palette, Grayscale-Palette-4bpp, will show up in the Palette Dialog.
  3. Select IMAGE->Mode->Indexed…
 

 

  1. In the Indexed Color Conversion dialog, select the Use custom palette radio button
    • Type the name of the palette.
    • IMPORTANT: Make sure that the "Remove unused color from colormap" is unchecked.
    • Select Convert
 

 

  1. The image will now be converted using a 16 grayscale color palette.
  2. Save the image as a Bitmap.
 

This image can now be converted by the GRC for use with the Microchip Graphics Library. 

 

Here is an example of a palette file *.gpl (Grayscale-Palette-4bpp.gpl)

GIMP Palette
Name: Greyscale Palette 4bpp
Columns: 0
#
  0   0   0    BLACK
 17  17  17    Untitled
 34  34  34    Untitled
 51  51  51    Untitled
 68  68  68    Untitled
 85  85  85    Untitled
102 102 102    Untitled
119 119 119    Untitled
136 136 136    Untitled
153 153 153    Untitled
170 170 170    Untitled
187 187 187    Untitled
204 204 204    Untitled
221 221 221    Untitled
238 238 238    Untitled
255 255 255    WHITE
Links
Microchip Graphics Library Version 3.06.02 - October 15, 2012
Copyright © 2012 Microchip Technology, Inc.  All rights reserved