Re: gif to binary data



In comp.arch.embedded,
tanu <tanumeister@xxxxxxxxx> wrote:
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


I am sorry, but I'm unable to understand what exactly you have tried
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);
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

You are not parsing the graphics file properly, read the stuff on wotsit.
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)

.



Relevant Pages

  • Re: gif to binary data
    ... i m using a 240*128 pix lcd with t6963c controller ... for graphics i thougt of converting the gif file to binary data ... i m getting binary data rite acording to the txt file but when i m ...
    (comp.arch.embedded)
  • Re: /boot/loader graphics support & extensibility
    ... They have VGA compatible hardware. ... Therefore all graphics functions must ... void gfx_setrgb(int color, int red, int green, int blue); ... x resolution, y resoluton, depth. ...
    (freebsd-hackers)
  • Re: MiniPix ProDOS and DOS33 Disks 1-3 ALL
    ... Purpose: Legacy Graphics Converter ... This program converts Apple IIe format Beagle Bros. ... Minipix size. ... int minihead = OLD_HEADER; ...
    (comp.sys.apple2.programmer)
  • Re: Resizing Images
    ... Doing so makes some of the later Graphics calls more convenient too. ... float scaleOutput = Math.Min; ... Just use the overload, or even the (Image, int, int, int, int) overload ... -- Finally, off the top of my head, my recollection is that specifying both the "quality" and "compression" for JPEG is superfluous. ...
    (microsoft.public.dotnet.languages.csharp)
  • Reply to Morten Wennevik: Drawing problem
    ... Graphics OffScreenGraphics = Graphics.FromImage; ... private void Main_Form_MouseDown(object sender, ... private void PaintToScreen1(int x, int y) ... int width = MouseX - startatX; ...
    (microsoft.public.dotnet.languages.csharp)