Did you find this site useful ? Please
to help www.micro-examples.com

If you need a coder or a freelance programmer, submit your project to me


Binary File to C, Basic and Pascal Converter

Printer-friendly version | Forums | FAQs |

File to source code convertor

You need to display a picture or a sprite on your GLCD, but you dont know how to convert it ?
You need to add a sound to your embedded application ?
You have a binary file to convert to a constant table ?

This tool is made for you !

 

Just select your file and click on the translate button, you will get a ready-to-use C, Basic and Pascal source code to copy and paste to your project.

If you check the GLCD box to convert a picture file, the input can be any format you have (BMP, GIF, JPEG, JPG, PNG, TIFF...). The picture can be resized to fit your display, then converted to monochrome. Don't forget to check the KS0108 box if your display has this controller.
A preview of the picture is available after the translation.

If you don't check the GLCD box, the input file will be dump to hexadecimal, any extension it has.

C source code example

This example shows you how to display a picture on a KS0108 128x64 GLCD connected on an EasyPIC4 (mikroC compiler) : the source code coming from the converter is added to the project with no modification.

Note that the byte array is defined as constant, so the compiler will put it in ROM.

/*
 *******************************************************************************
 * KS0108 GLCD bitmap image example
 *******************************************************************************
 *
 * source code example for mikroC
 * feel free to use this code at your own risks
 *
 * Author : Bruno Gavand, September 2007
 * see more details on http://www.micro-examples.com/
 *
 *******************************************************************************
 */

/*
 * On-line file converter for mikroC
 * Source file name : C:\tmp\map_image.png
 * File size : 1024 bytes
 * Generated on Thu Sep  6 15:34:15 2007 GMT
 * See more details on http://www.micro-examples.com/
 * This source code is given 'as is' with no guarantee
 * Use it at your own risks
 */

#define	WIDTH_MAP_IMAGE_PNG	128
#define	HEIGHT_MAP_IMAGE_PNG	64

#define	DUMP_MAP_IMAGE_PNG_SIZE	1024

const unsigned char dump_map_image_png[DUMP_MAP_IMAGE_PNG_SIZE] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x40, 0x00, 0x40, 0xc0, 0x40, 0x40, 0x40, 0x10, 0x40, 0x10, 0x88, 0xdc, 0xdc, 0x3c, 0xfe, 0x3e,
0x1e, 0x0e, 0x2e, 0x36, 0x76, 0x3c, 0x7c, 0x7e, 0xfc, 0xfc, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, 0xff,
0xff, 0xfe, 0xfe, 0xfe, 0xfc, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x30, 0x18, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xc8, 0x98, 0xd0,
0xf0, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xb8, 0xbc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xfc, 0xf8,
0xfb, 0xd9, 0xfb, 0xf7, 0xfe, 0xfe, 0xf6, 0xf8, 0xf1, 0xfa, 0xff, 0x79, 0x32, 0x37, 0x5f, 0x07,
0x06, 0xbe, 0xbc, 0x7c, 0x70, 0x10, 0x00, 0x00, 0x01, 0x3f, 0xff, 0xff, 0xff, 0x3f, 0x1f, 0x1f,
0x0f, 0x07, 0x0f, 0x05, 0x60, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0,
0xe0, 0xf0, 0x78, 0x78, 0xdc, 0xfc, 0xfc, 0xf8, 0xd8, 0xd8, 0xf0, 0xe0, 0xf0, 0xf0, 0xfa, 0xf3,
0xf8, 0xf8, 0xf8, 0xf8, 0xfe, 0xfe, 0xf6, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xfe, 0xfc, 0xfe, 0xfc, 0xfe, 0xff, 0xfe,
0xfe, 0xfc, 0xfc, 0xfc, 0xfc, 0xf8, 0xf8, 0xf8, 0xf8, 0xfc, 0x78, 0x38, 0x18, 0x30, 0x30, 0x00,
0x00, 0x00, 0x01, 0x03, 0x03, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x03, 0x07, 0x1f, 0x3f,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xbc, 0xb8, 0x78, 0xf0,
0xff, 0xff, 0xff, 0xfe, 0xde, 0xbe, 0x1c, 0x38, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x2c, 0xd8, 0xd0, 0xe0, 0xf9, 0xf5,
0x77, 0xfb, 0xf8, 0xec, 0xff, 0xfe, 0x7f, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff,
0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x33, 0x31, 0x01,
0x01, 0x01, 0x01, 0x0c, 0x0e, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x07, 0x0f, 0x1f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x3f, 0x3f, 0x1f, 0x7e, 0x1f,
0x0f, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xf7, 0xf7, 0xff, 0xfb, 0xf8, 0xf8, 0xf9,
0xe1, 0xe6, 0xe1, 0xe7, 0xe5, 0xe3, 0xe6, 0xe6, 0x76, 0xfe, 0xff, 0xff, 0xff, 0xbc, 0x79, 0x7f,
0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfb, 0x03, 0x03, 0x0f, 0x11, 0x11, 0x08, 0x0c, 0x01, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x06, 0x04, 0x0c, 0x0e, 0x18, 0x00, 0x20,
0x62, 0xe0, 0xe4, 0xe0, 0xe0, 0xe0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x3f, 0x7f, 0x7f, 0x7f, 0x7f, 0x3f, 0x7f, 0x7f, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xfb, 0xff, 0xef, 0x67, 0x07, 0x07,
0x03, 0x00, 0x00, 0x00, 0x01, 0x01, 0x0f, 0x3f, 0x2f, 0x03, 0x03, 0x01, 0x01, 0x03, 0x87, 0x9f,
0x9f, 0x1f, 0x19, 0x01, 0x81, 0x81, 0x00, 0x28, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,
0x1f, 0x3f, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xfc, 0x1c, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x11, 0x01, 0xc0, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x03, 0x06, 0x08, 0x03, 0x03, 0x01, 0x06, 0x82, 0xc0, 0xc0, 0xe0, 0xe6, 0xc4, 0x8e, 0xec, 0xc4,
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x7f, 0x7f, 0x3f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x1f, 0x3f, 0x1f, 0x1f, 0x0f, 0x07, 0x02, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x06, 0x3f, 0x3f, 0x1f, 0x1f, 0x1f, 0x0f, 0x1f, 0x3f, 0x3f, 0x7f, 0x7f,
0x7f, 0x3e, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0c, 0x3f, 0x6f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } ;

void main()
        {
        Glcd_Init(&PORTB, 0, 1, 2, 3, 5, 4, &PORTD) ;
        Glcd_Image(dump_map_image_png);
        }

Please report bugs & suggestions to my forum.

 

All trademarks and registered trademarks are the property of their respective owners