Re: gif to binary data
- From: Stef <stef33d@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 13 Sep 2006 14:38:47 +0200
In comp.arch.embedded,
tanu <tanumeister@xxxxxxxxx> wrote:
hi allI am sorry, but I'm unable to understand what exactly you have tried
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
to do here.
A GIF file is a graphics file in a specific format that you need to
parse to get the image. See www.wotsit.org for the GIF file format.
But you may want to start of with something like the BMP format as
it is much easier to decode (also see wotsit for the format).
#include <stdlib.h>
#include <stdio.h>
#include<conio.h>
This is a non-standard header, what is your platform?
typedef unsigned char byte;
#define SIZEBMP 3840
240 * 128 / 8
#define SIZELCD 42240
Where does this number come from?
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];
Why are these variable global?
main()
int main(void)
{
clrscr();
FILE *fp;
/* open the bitmap for reading in binary mode */
if ( (fp = fopen("\\compass22.txt", "r")) == NULL)
Binary mode? --> "rb"
{
fprintf(stderr, "Error opening file.");
}
Program gets here if open suceeded or not
fp = fopen("\\compass22.txt", "r");
Open again? That will probably fail.
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);
Ok file now closed, your indentation makes it seem like it's in
a loop, but it's not.
if ( (fp = fopen("\\compass234.txt", "w+b")) == NULL)
{
fprintf(stderr, "Error opening file.");
exit(1);
Now you do something on an error,
}
fp = fopen("\\compass234.txt", "wb");
But you als open the file twice, why? And in different modes this time.
fwrite(arrayLCD, sizeof(byte), SIZELCD, fp);You are not parsing the graphics file properly, read the stuff on wotsit.
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
Your variable names seem to suggest you are using the BMP format but you
say you are using GIF.
--
Stef (remove caps, dashes and .invalid from e-mail address to reply by mail)
.
- References:
- gif to binary data
- From: tanu
- gif to binary data
- Prev by Date: Re: gif to binary data
- Next by Date: Re: HP calculator is back
- Previous by thread: Re: gif to binary data
- Next by thread: Re: gif to binary data
- Index(es):
Relevant Pages
|