gif to binary data



hi all
i m using a 240*128 pix lcd with t6963c controller
wanna see the graphics in it
lcd is interfaced with atmega 128 microcontroller

for graphics i thougt of converting the gif file to binary data so did
this
i had 1st save the gif file in to the txt
so to get ascii data
before i aslo tried direct gif to binary
i m getting binary data rite acording to the txt file but when i m
seeing this data
in the lcd i m not getting that image
infact i had discarded the 22 bytes from the data


#include <stdlib.h>
#include <stdio.h>
#include<conio.h>
typedef unsigned char byte;
#define SIZEBMP 3840
#define SIZELCD 42240
static int i;
int ig,jg;
unsigned char tg;
int y;
char kg[8];
void convert(void);
//byte getvertByte(int ,int bit);
unsigned char getbits(unsigned x, int p, int n);
byte count, arrayLCD[SIZELCD], arrayBmp[SIZEBMP];
main()
{
clrscr();
FILE *fp;

/* open the bitmap for reading in binary mode */

if ( (fp = fopen("\\compass22.txt", "r")) == NULL)
{
fprintf(stderr, "Error opening file.");
}

fp = fopen("\\compass22.txt", "r");
fread(arrayBmp, sizeof( byte), SIZEBMP, fp);
for(ig=0;ig<SIZEBMP;ig++)
{
printf("%c",arrayBmp[ig]);
for(y=0;y<sizeof(char)*8;y++)
{
kg[y]=arrayBmp[ig] & (1<<y)?'1':'0';
}
for(y=7,jg=0;y>=0,jg<8;y--,jg++)
{
printf("%c",kg[y]);
arrayLCD[11*ig+jg]=kg[y];
}
if(jg==8)
{arrayLCD[11*ig+jg]=',';
jg++;
arrayLCD[11*ig+jg]='0';
jg++;
arrayLCD[11*ig+jg]='b';}
}
printf("\n\n\n");

fclose(fp);

if ( (fp = fopen("\\compass234.txt", "w+b")) == NULL)
{
fprintf(stderr, "Error opening file.");
exit(1);
}
fp = fopen("\\compass234.txt", "wb");
fwrite(arrayLCD, sizeof(byte), SIZELCD, fp);
for(ig=0;ig<SIZELCD;ig++)
{
printf("%c",arrayLCD[ig]);
}
fclose(fp);

return(0);
}





so do tell me where m i wrong
and do tell if there is any other way to find the binary data

.



Relevant Pages

  • Re: printf
    ... I have a pointer that points to binary data, and I want to print that ... void binprint ... int main ...
    (comp.lang.c)
  • LCD problem with ATmega16 and CVAVR
    ... which has a library of lcd ... That resulted perfectly correct displaying of text "hello world" on the ... I also tried changing the data type of the h from int to char and ...
    (sci.electronics.misc)
  • [RFC 2.6.12-rc5 1/1] Framebuffer driver for Arc LCD board
    ... Appended is my patch adding support for the Arc monochrome LCD board. ... +unsigned int arcfb_enable; ... +static void ks108_writeb_data(struct arcfb_par *par, ...
    (Linux-Kernel)
  • [RFC/PATCH 2.6.12-rc5 1/1] Framebuffer driver for Arc LCD board
    ... Appended is my patch adding support for the Arc monochrome LCD board. ... +static unsigned int arcfb_enable; ... +static void ks108_writeb_mainctl(struct arcfb_par *par, ...
    (Linux-Kernel)
  • Re: Measuring refrigeration power draw.
    ... the weird binary data coming out of the meter into something ... listens to the serial port ... int make_value ... in those bytes is one of the lcd elements ... ...
    (rec.boats.cruising)