Converting bitmap images into an array and using them in a sketch

Could somebody please explain how to convert bitmap images into an array and how to use the converted information in a sketch. I can display the standard bitmaps within the IDE to work without any problems, but despite spending 2 days trying to display a simple AC symbol and failing, I've come to the conclusion it's either very tricky or I'm an idiot.

I've used LCD assistant and The Dot Factory. I can get an array and headers from either program. The problem is what to do with them. What ever I try I end up with a sketch that doesn't compile.

I'd be really grateful for any help or tips.

Thanks
Scott.

The first thing is to provide the means for us to help you.

Post the code, all of it.
Post the error messages (all of them, verbatim).
Tell us which LCD, how you've wired it up, and the sketch you've tried that actually works...
Oh, and post links to the tools you mention please.

Many thanks for the reply.

This is the code I've used to draw a crosshair on the screen with an Arduino bitmap and a letter W. This seems to work ok.

#include <glcd.h>
#include "fonts/allFonts.h"
#include "Bitmaps/allBitmaps.h"

void setup () {
GLCD.Init(NON_INVERTED); // Initialise the glcd library
GLCD.ClearScreen(); // Clear Screen
}

void loop ()
{
showDisplay(); // display data *NECESSARRY!
}

void showDisplay(){
GLCD.SelectFont(Arial14);
GLCD.GotoXY(50,50);
GLCD.Puts("W");

GLCD.DrawLine(0,32,128,32 ,BLACK); // HORIZONTAL LINE
GLCD.DrawLine(64,180,64,0 ,BLACK); // VERTICAL LINE
GLCD.DrawBitmap(ArduinoIcon32x32,30,0, BLACK); //Call bitmap from Arduino Library and draw it to a XY point
}

I used a bitmap creator called LCD assistant to change a monochrome bitmap image of an AC symbol into an array. The software can be found here : Bitmap converter for mono and color LCD displays

I then saved the image to the bitmap library within Arduino. I couldn't get this to compile in a sketch and reading several forum entries I discovered that LCD assistant can give arrays that will not work. Someone suggested The Dot Factory located here : Home - Technology In The Arts - Emerging Science and Technology Trends

With the array it produced I saved it as AClogo.h in the folder my main sketch called LCD quarters is saved in. This is the code I got from The Dot Factory :

include <avr/pgmspace.h>

include <inttypes.h>

ifndef AClogo_H

define AClogo_H

static uint8_t AClogo[] PROGMEM={
//

const uint_8 aClogoBitmaps =
{
0x00, 0x07, 0xFC, 0x00, 0x00, // #########
0x00, 0x3F, 0xFF, 0x80, 0x00, // ###############
0x00, 0x7C, 0x03, 0xE0, 0x00, // ##### #####
0x01, 0xE0, 0x00, 0xF0, 0x00, // #### ####
0x03, 0x80, 0x00, 0x38, 0x00, // ### ###
0x07, 0x00, 0x00, 0x0E, 0x00, // ### ###
0x0E, 0x00, 0x00, 0x06, 0x00, // ### ##
0x1C, 0x00, 0x00, 0x03, 0x00, // ### ##
0x38, 0x00, 0x00, 0x03, 0x80, // ### ###
0x30, 0x00, 0x00, 0x01, 0x80, // ## ##
0x70, 0x00, 0x00, 0x00, 0xC0, // ### ##
0x60, 0x38, 0x00, 0x00, 0xC0, // ## ### ##
0x60, 0xFE, 0x00, 0x00, 0x60, // ## ####### ##
0xC1, 0xC7, 0x00, 0x00, 0x60, // ## ### ### ##
0xC1, 0x83, 0x00, 0x00, 0x60, // ## ## ## ##
0xC3, 0x01, 0x80, 0x00, 0x60, // ## ## ## ##
0xC7, 0x01, 0xC0, 0x00, 0x60, // ## ### ### ##
0xC6, 0x00, 0xE0, 0x00, 0x30, // ## ## ### ##
0xC0, 0x00, 0x60, 0x0C, 0x30, // ## ## ## ##
0xC0, 0x00, 0x30, 0x0C, 0x60, // ## ## ## ##
0xC0, 0x00, 0x38, 0x18, 0x60, // ## ### ## ##
0xC0, 0x00, 0x1C, 0x38, 0x60, // ## ### ### ##
0xC0, 0x00, 0x0E, 0x70, 0x60, // ## ### ### ##
0x60, 0x00, 0x07, 0xE0, 0x60, // ## ###### ##
0x60, 0x00, 0x01, 0x80, 0xC0, // ## ## ##
0x70, 0x00, 0x00, 0x00, 0xC0, // ### ##
0x30, 0x00, 0x00, 0x01, 0x80, // ## ##
0x18, 0x00, 0x00, 0x03, 0x80, // ## ###
0x1C, 0x00, 0x00, 0x07, 0x00, // ### ###
0x0E, 0x00, 0x00, 0x0E, 0x00, // ### ###
0x07, 0x00, 0x00, 0x1C, 0x00, // ### ###
0x03, 0x80, 0x00, 0x38, 0x00, // ### ###
0x01, 0xE0, 0x00, 0xF0, 0x00, // #### ####
0x00, 0x7C, 0x07, 0xC0, 0x00, // ##### #####
0x00, 0x1F, 0xFF, 0x00, 0x00, // #############
0x00, 0x03, 0xF8, 0x00, 0x00, // #######
};

// Bitmap sizes for aClogo
const uint_8 aClogoWidthPages = 5;
const uint_8 aClogoHeightPixels = 36;

// Bitmap info for aClogo
extern const uint_8 aClogoBitmaps;
extern const uint_8 aClogoWidthPages;
extern const uint_8 aClogoHeightPixels;

#endif //define AClogo_H

I changed the already working code called glcd_quarters to include AClogo.h and called this bitmap so the sketch now looks like this :

#include <glcd.h>
#include "fonts/allFonts.h"
#include "Bitmaps/allBitmaps.h"
#include "AClogo.h"

void setup () {
GLCD.Init(NON_INVERTED); // Initialise the glcd library
GLCD.ClearScreen(); // Clear Screen
}

void loop ()
{
showDisplay(); // display data *NECESSARRY!
}

void showDisplay(){
GLCD.SelectFont(Arial14);
GLCD.GotoXY(50,50);
GLCD.Puts("W");

GLCD.DrawLine(0,32,128,32 ,BLACK); // HORIZONTAL LINE
GLCD.DrawLine(64,180,64,0 ,BLACK); // VERTICAL LINE
GLCD.DrawBitmap(Aclogo,30,0, BLACK); //Call bitmap from folder and draw it
}

These are the compiler errors :

In file included from glcd_quarters.cpp:5:
AClogo.h:8: error: expected primary-expression before 'const'
AClogo.h:8: error: expected `}' before 'const'
AClogo.h:8: error: expected ',' or ';' before 'const'
AClogo.h:49: error: 'uint_8' does not name a type
AClogo.h:50: error: 'uint_8' does not name a type
AClogo.h:54: error: 'uint_8' does not name a type
AClogo.h:55: error: 'uint_8' does not name a type
AClogo.h:56: error: 'uint_8' does not name a type
glcd_quarters.cpp: In function 'void showDisplay()':
glcd_quarters:25: error: 'Aclogo' was not declared in this scope

Any help or advice would be greatly received.

Its not hard, but it's not particularly obvious.
There are MANY different formats for graphic data.
There are several different standardized formats as well. XBM, GIF, jpeg, png, etc...
However, in many cases standardized formats cannot be used in embedded system
environments.

The glcd v3 library currently requires that the bitmap data be stored in the same bitmap
form as the internal ks0108/sed1520 glcd memory format with
the exception of having a 2 byte descriptor in front that describes the geometry
of the image data that follows.
Data is stored glcd page by glcd page from left to right across the row, then top to bottom
for each row. Pixels are stored lsb to msb top to bottom within the byte/page.

I'm not sure what format the data you have created is in, but for sure it is not the format
that the glcd bitmap routine wants as for sure it is missing the geometry data.
The data must also be stored in progmem rather than RAM.
You can look at one of the other bitmap header files for reference.

Have a read of the html documentation that is included with the glcd library.
Pointers to where that is located are in the readme and on the ks0108 playground site.
The documentation is quite extensive. There is a section on how to create bitmaps and fonts.
The library even includes a java based tool to convert your image file to the proper file format for the glcd library.
It does the conversion, creates the header files, and even updates the allBitmaps.h header file for you.
It supports tif, jpeg, bmp, tga, png all using a simple drag and drop interface.
i.e. if you have an image you have created, all you do is drop it into the glcdMakeBitmap tool
and it does the rest.

---- bill

Bill - Thank so much, I've finally got one to work!

Thanks for your time. I can't tell you how much you've helped me!

Very much appreciated.

Scott.

Did you end up using the glcdMakeBitmap tool?

Before this, did you know about the html documentation?
Just curious as many glcd library users seem to over look it and
miss out on it.
Not sure what I could do to make things easier/better.

--- bill

Hi all!

I was looking for a easy to use tool to convert images to arrays. So I ended up writing my own. It's just a single file so you can download it if you want, and runs in your browser:
http://logotype.se/image-converter-arduino/

Please test it and let me know if it works. I've tested it successfully with a 128x64 display.

Victor