gif to binary data
- From: "tanu" <tanumeister@xxxxxxxxx>
- Date: 13 Sep 2006 04:50:35 -0700
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
.
- Follow-Ups:
- Re: gif to binary data
- From: Tom Lucas
- Re: gif to binary data
- From: Stef
- Re: gif to binary data
- From: Boudewijn Dijkstra
- Re: gif to binary data
- Prev by Date: Re: SD Card FAT support issues (dosfs, fatfs,fatlib)
- Next by Date: Re: Embedded software interview question collection
- Previous by thread: Embedded software interview question collection
- Next by thread: Re: gif to binary data
- Index(es):
Relevant Pages
|