Arduino GLCD Library: Using Bitmaps

# Using Bitmaps

You can use the distributed bitmaps or create your own. The distribution contains a file named allBitmaps.h that includes all the distributed bitmaps, so you can include this to make the bitmaps available:

    #include "bitmaps/allBitmaps.h"  // all distributed bitmaps

Note:
  Included bitmaps will not consume any memory if they are not explicitly referenced in your sketch with the DrawBitmap() function.

You can also display your own images in your sketch.

A utility located in the glcd/bitmaps/utils converts a gif, jpg, bmp, tga or png file to a header file that can be used by your sketch.

The utility is written in the Processing language; However, a java version of the utilty is also provided. The Processing file glcdMakeBitmap.pde located in the glcdMakeBitmap subdirectory runs in the Processing environment on your computer - its not an Arduino sketch. See: http://processing.org/

The java runtime (glcdMakeBitmap.jar) and java source (glcdMakeBitmap.java) are located in the Java subdirectory.

Run the utility by either running the java jar file directly or loading the pde file into Processing.

Drop the image file to be converted into the window. If the image can be converted, the image will be displayed in the window and a header file is created in the bitmap directory. For example, if the image file name to be converted is named image.bmp, the header is named image.h

To use the newly created bitmap, add the following line to the sketch:

    #include "bitmaps/image.h"

and display the image using the following code:

      GLCD.DrawBitmap(image, x, y);

where x and y are the desired location of the upper left edge of the bitmap.

The utility can also update the aggregate header file (named allBitmaps.h). Including allBitmaps.h in your sketch makes all images in the bitmaps directory available. Flash memory is only consumed for images that are explicitly used by your code so there is no penalty using this file instead of explicitly including header files.

To update allBitmaps.h to include all header files in the bitmap directory, click the window.

Images are stored in program memory, a 128x64 pixel image takes 1k bytes of flash. Bear in mind that each different image used in a sketch will reduce the amount of code in a sketch. The utility displays the amount of memory required for the image and other useful information when it does the conversion.