How to use mikroElektronika’s GLCD bitmap editor tool to convert a BMP image in to a data array

MikroElektronika's GLCD BMP editor

This tutorial describes how to use the mikroElektronika’s GLCD bitmap editor tool to convert a monochromatic bit map (BMP) image file into a data array so that it could be displayed on a graphics LCD using a microcontroller. The GLCD bitmap editor tool is embedded into mikroElektronika’s compilers. It can generate a code equivalent of a BMP image, which can be easily inserted into the microcontroller’s source program.

MikroElektronika's GLCD BMP editor

Here I am using a NT7107/8 based (compatible with Samsung KS0107/8) 128×64 graphics LCD display. I will show how to convert the Microchip Technology logo into a constant data array and display it on the LCD that is driven by a PIC microcontroller. I will be demonstrating this with mikroC Pro for PIC compiler. The circuit diagram below shows the GLCD connections to the PIC16F887 microcontroller. The circuit is self-explanatory and not described in further detail.

GLCD connections to PIC16F887

The picture below shows a 128×64 pixels Microchip Technology logo. It should be first converted into a monochromatic BMP image. In Windows, the MS Paint application can do that for you. First open the image with MS Paint and then save it choosing Monochrome Bitmap format.

Microchip logo

Now open the GLCD bitmap editor application from the Tools menu of mikroC Pro for PIC compiler. Select the size and the controller of the GLCD display that you are using. I selected 128×64 (KS0108) from the available options. Next, click on Load BMP button and select the BMP file that you want to convert. It will then display the code for the display image inside the Generated Code section. Copy the code and either paste it into your main program or to another file that is to be included into the main program. You can also select the type of compiler you are using so that it could generate the code accordingly.

MikroElektronika's GLCD BMP editor

The generated code is nothing else than a constant character array that contains the information about what pixels of the 128×64 GLCD are to be illuminated to display the image. The code generated will look like this:

// -- ----------------------------------------------------
// GLCD Picture name: Microchip.bmp
// GLCD Model: KS0108 128x64
// ------------------------------------------------------  

const code char Microchip[1024] = {
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  7,  15,  15,  31,  31,
  31,  63,  63,  63,  63,  63,  63,  63,  63,  ...
  ... 12,  12,  12,  12, 127, 127, 127,   0,   0, 127, 127, 127,   0,   0, 127,  0
};

For an LCD of 128×64 size, the size of the array would be 1024 bytes (1024×8 = 8192 bits), which hold information bits of all 128×64 = 8192 display pixels. With mikroC, it is very easy to load the image data into a GLCD using the built-in GLCD library routines. The Glcd_Image(Microchip) command will display the Microchip Technology logo into the GLCD screen.

Download the complete mikroC program

Microchip Technology logo displayed on a GLCD


Related Posts

6 comments

  • AOUDUMBAR PAWAR

    #include
    #define RS_SET (IO0SET|=(1<<10))
    #define RS_CLR (IO0CLR|=(1<<10))
    #define EN_HIGH (IO0SET|=(1<<9))
    #define EN_LOW (IO0CLR|=(1<<9))
    #define CS1_HIGH (IO0SET|=(1<<11))
    #define CS1_LOW (IO0CLR|=(1<<11))
    #define CS2_HIGH (IO0SET|=(1<<12))
    #define CS2_LOW (IO0CLR|=(1<<12))
    unsigned char c;
    unsigned char Z=0;
    void PORT_INTI();
    void LCD_INTI();
    void CLMN_SLCT(unsigned char);
    void PAGE_SLCT(unsigned char);
    void DISP_DATA(unsigned char Y,unsigned char X,const char *str);
    void delay(unsigned int);
    void SET_STRT_LINE(unsigned char);
    void send_data (unsigned char);
    const char img[900] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0xFF, 0xFF, 0xFF,
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC3, 0x00, 0x01, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC4, 0x80, 0x01, 0x00, 0x00, 0xE0, 0x07, 0xF8, 0x01,
    0x7E, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0xE4, 0x83, 0x01, 0x00, 0x00, 0xF0, 0x07, 0xF8, 0x01, 0x7E,
    0xC0, 0x0F, 0x00, 0x00, 0x00, 0xE4, 0x83, 0x01, 0x00, 0x00, 0xE0, 0x07, 0xF8, 0x01, 0x7E, 0xC0,
    0x0F, 0x00, 0x00, 0x00, 0xC4, 0x80, 0x01, 0x00, 0x00, 0xF0, 0x07, 0xF8, 0x01, 0x7E, 0xC0, 0x0F,
    0x00, 0x00, 0x00, 0x84, 0x80, 0x01, 0x00, 0x00, 0xF0, 0x07, 0xF8, 0x01, 0x7E, 0xC0, 0x0F, 0x00,
    0x00, 0x00, 0x80, 0x80, 0x01, 0x00, 0x00, 0xF0, 0x07, 0xF8, 0x01, 0x7E, 0xC0, 0x0F, 0x00, 0x00,
    0x00, 0x80, 0x80, 0x01, 0x00, 0x00, 0xF0, 0x07, 0xF8, 0x01, 0x7E, 0xC0, 0x0F, 0x00, 0x00, 0x00,
    0x80, 0x80, 0x01, 0x00, 0x00, 0xF0, 0x07, 0xF8, 0x01, 0x7E, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0x80,
    0x80, 0x01, 0x00, 0x00, 0xE0, 0x07, 0xF8, 0x01, 0x7E, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0x80, 0x80,

    0x01, 0x00, 0x00, 0xF0, 0x07, 0xF8, 0x01, 0x7E, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01,
    0x00, 0x00, 0xF0, 0x07, 0xF8, 0x01, 0x7E, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01, 0x00,
    0x00, 0xF0, 0x07, 0xF8, 0x01, 0x7E, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01, 0xFF, 0xFF, 0x03,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0x01, 0x80, 0x80, 0x01, 0xFF, 0xFF, 0x03, 0x00,
    0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x01, 0x80, 0x80, 0x01, 0xFF, 0xFF, 0x03, 0x00, 0x00,
    0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x01, 0x80, 0x80, 0x01, 0xFF, 0xFF, 0xC3, 0x07, 0x0E, 0xFC,
    0x87, 0x81, 0xC7, 0xFF, 0xFF, 0x01, 0x80, 0x80, 0x01, 0xFF, 0xFF, 0xC3, 0x0F, 0x0E, 0xFF, 0xCF,
    0xC3, 0x87, 0xFF, 0xFF, 0x01, 0x80, 0x80, 0x01, 0x00, 0x00, 0xC0, 0x1F, 0xCE, 0xFF, 0xCF, 0xF3,
    0x01, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01, 0x00, 0x00, 0xC0, 0x1F, 0xCE, 0x07, 0xC0, 0xF3, 0x01,
    0x00, 0x00, 0x00, 0x80, 0x80, 0x01, 0xFF, 0xFF, 0xC3, 0x3F, 0xCE, 0x07, 0xC0, 0x3F, 0x00, 0x00,
    0x00, 0x00, 0x80, 0x80, 0x01, 0xFF, 0xFF, 0xC3, 0x7F, 0x8E, 0xFF, 0xC7, 0xFF, 0xC7, 0xFF, 0xFF,
    0x00, 0x80, 0x80, 0x01, 0xFF, 0xFF, 0xE3, 0xF3, 0x0E, 0xFF, 0xCF, 0xFF, 0xCF, 0xFF, 0xFF, 0x00,
    0x80, 0x80, 0x01, 0xFF, 0xFF, 0xC3, 0xE3, 0x0F, 0x00, 0xDE, 0x79, 0xC0, 0xFF, 0xFF, 0x00, 0x80,
    0x80, 0x01, 0xFF, 0xFF, 0xC3, 0xC3, 0x0F, 0x00, 0xDE, 0x7B, 0xC0, 0xFF, 0xFF, 0x00, 0x80, 0x80,
    0x01, 0x00, 0x00, 0xC0, 0x83, 0x8F, 0xFF, 0xCF, 0xE3, 0x03, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01,

    0x00, 0x00, 0xC0, 0x83, 0x8F, 0xFF, 0xCF, 0xC3, 0x07, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01, 0xFF, 0xFF,
    0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x00, 0x80, 0x80, 0x01, 0xFF, 0xFF, 0x03,
    0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x01, 0x80, 0x80, 0x01, 0xFF, 0xFF, 0x03, 0x00,
    0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x00, 0x80, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01, 0x00, 0x00, 0xE0, 0x0F, 0xF0, 0x03, 0x7C,
    0xC0, 0x1F, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01, 0x00, 0x00, 0xE0, 0x0F, 0xF0, 0x03, 0x7C, 0xC0,
    0x1F, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01, 0x00, 0x00, 0xE0, 0x0F, 0xF0, 0x03, 0x7C, 0xC0, 0x1F,
    0x00, 0x00, 0x00, 0x80, 0x80, 0x01, 0x00, 0x00, 0xE0, 0x0F, 0xF0, 0x03, 0x7C, 0xC0, 0x1F, 0x00,
    0x00, 0x00, 0x80, 0x80, 0x01, 0x00, 0x00, 0xE0, 0x0F, 0xF0, 0x03, 0x7C, 0xC0, 0x1F, 0x00, 0x00,
    0x00, 0x80, 0x80, 0x01, 0x00, 0x00, 0xE0, 0x0F, 0xF0, 0x03, 0x7C, 0xC0, 0x1F, 0x00, 0x00, 0x00,
    0x80, 0x80, 0x01, 0x00, 0x00, 0xE0, 0x0F, 0xF0, 0x03, 0x7C, 0xC0, 0x1F, 0x00, 0x00, 0x00, 0x80,
    0x80, 0x01, 0x00, 0x00, 0xE0, 0x0F, 0xF0, 0x03, 0x7C, 0xC0, 0x1F, 0x00, 0x00, 0x00, 0x80, 0x80,
    0x01, 0x00, 0x00, 0xE0, 0x0F, 0xF0, 0x03, 0x7C, 0xC0, 0x1F, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01,
    0x00, 0x00, 0xE0, 0x0F, 0xF0, 0x03, 0x7C, 0xC0, 0x1F, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01, 0x00,

    0x00, 0xE0, 0x0F, 0xF0, 0x03, 0x7C, 0xC0, 0x1F, 0x00, 0x00, 0x00, 0x80, 0x80, 0x01, 0x00, 0x00,
    0xE0, 0x0F, 0xF0, 0x03, 0x7C, 0xC0, 0x3F, 0x00, 0x00, 0x00, 0x80, 0x83, 0x01, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x83, 0x01, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x83, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x83, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x87, 0xDF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0xF4, 0x7F, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0xFA, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    };
    int main (void)
    {
    PORT_INTI();
    while(1)
    {
    LCD_INTI();
    CLMN_SLCT(0);
    PAGE_SLCT(0);
    DISP_DATA(0,0,img);
    }
    }
    void PORT_INTI()
    {
    PINSEL0=0x00000000; // port 0 as gpio
    IO0DIR=0xffffffff; //set port 0 pins as output pins
    }
    //——-LCD Initialise————-
    void LCD_INTI()
    {
    IO0PIN=0x3f; // D0=1 to ON LCD
    CS1_HIGH; // enable half1
    CS2_HIGH; // enable half2
    RS_CLR; // RS=0 to select command
    EN_HIGH;
    delay(5000);
    EN_LOW;
    }
    //———-page selection——–
    void PAGE_SLCT(unsigned char X) //select page0 – 7
    {
    IO0PIN=(0xb8|X);// select page 0
    CS1_HIGH;
    CS2_HIGH;
    RS_CLR;
    EN_HIGH;
    delay(5000);
    EN_LOW;
    }
    //——-column selection
    void CLMN_SLCT(unsigned char Y)
    {
    if(Y<=63)
    {
    IO0PIN=((0x40)|(63&Y)); // select column 0 to 63
    CS1_HIGH; // enable 1st half
    CS2_LOW; // desable 2nd half
    RS_CLR;
    EN_HIGH;
    delay(5000);
    EN_LOW;
    }
    else
    {
    IO0PIN=(0x40|((Y-64)&63)); // select column 64 to 127
    CS1_LOW; // desable 1st half
    CS2_HIGH; // enable 2nd half
    RS_CLR;
    EN_HIGH;
    delay(5000);
    EN_LOW;
    }
    }
    //——–display data comand
    void send_data(unsigned char data) //select page0 – 7
    {
    IO0PIN=data;
    CS1_LOW;
    CS2_LOW;
    RS_SET;
    EN_HIGH;
    delay(5000);
    EN_LOW;
    }
    //——function to display single character
    void DISP_DATA(unsigned char X,unsigned char Y,const char *str)
    {
    unsigned int i;
    unsigned int a;
    for(X=0;X<8;X++)
    {
    for(Y=0;Y<128;Y++)
    {
    send_data(*str++);
    }
    }
    }
    void delay(unsigned int i)
    {
    unsigned int j;
    for(j=0;j<=i;j++);
    }

    i want to display image on glcd using lpc2148. my program is as above but there is no image created on glcd. i am simulating same in protious

  • can anyone give me link for this software..
    i have to convert image to hex code

  • Dude this works great! I Had a very small 13 X 13 image I wanted to get on the screen and when I loaded it into the image creator the generated code was only for the 13 X 13 image, I didn’t even have to trim out all the zeros for the 128 X 64 display…..
    Thanks
    Dick

  • Dear Sir,

    i want mikroElektronika’s GLCD bitmap editor exe file.

    thank you.

  • that was really helpful..
    Thanks a lot!

  • Pingback: Electronics-Lab.com Blog » Blog Archive » Converting bitmap image files to GLCD data array

Leave a Reply

Your email address will not be published. Required fields are marked *