Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

gif decoding and LZW compression

Status
Not open for further replies.

Dr_Doggy

Well-Known Member
I am hoping someone in here has experience with this and can help with this last step:


using the aid of the tutorials i was able to rip a gif file to hex and find most of the header and details, but the image is compressed somehow,

here is as far as i got with this, it should be a black(or some colour) square 10x10:

IMAGE 3
21 F9 04 05 21 00 05 00 2C 00 00 00 00 0A 00 0A 00 00 03-GraphicExtension&ImageDescriptor

09 08 BA DC FE 30 CA 49 6B 4C ------- IMAGE data under LZW compression


BEST i could decipher the IMAGE LINE to:

1001000000
0010000000
1011101011
0111000000
1111111000
0000110000
1100101000
0001001001
0000011010
1101001100

not a blk square thou:(

i think i got lost when it started going from 8bit to 9 bit or something....
 
Last edited:
thnx, but here is the tutorial i used, specifically since i was able to id all the headers, but i got lost when i got to the "IMAGE DECODING" section,

you will see in the text file i was able to get all the info however, that last line is killin me


09 08 BA DC FE 30 CA 49 6B 4C
 
i seen the algorithm but im just not gettin it, maybe it could help me if you can simplify the process, ie:

1) convert 8-bit to 9 bit
2) subtract char in table from 9 bit
3)add remainder to next 9bit
4)repeat

that is what i am understanding,, but then how do you get that first number to subtract?
 
I've got an old book somewhere, about programming video cards and formats - if I can find it I'll have a look.

It was written to use C, and I spent most of my time converting it to Pascal.
 
Most people are using SD cards for image storage now in microcontroller projects?

It might be easier (maybe even faster) to just store the images in 8bit uncompressed BMP format, then read it out directly off the card to video RAM. SD card have ton's of storage and it saves a lengthy decompression process in the microcontroller.
 
Last edited:
thnx nigel, dont worry about digging too much, i can go bug the vb guys, i just figured it was close enough to electronics that someone would kno, but maybe you can look at this link that i am using:
https://en.wikipedia.org/wiki/Graphics_Interchange_Format

i was able to find the data easy for the most of it, but look at the image decoding section, that is where im hanging.

i have read that ther are several steps, i think i have interpreted it as
1) convert to 9bit
2)remove the byte,
3)then something about subtraction...and using the previous number to subtract the next code......

the tutorial earlier in the post also mentioned about how it clumps lines with the same color, ie c-c-c-c-c-c =6c, but it doesnt mention how it is written for the compressor, ie 6c, is that how it would show?

also i have gotten as far as finding my palet table in the code:
00 FF 00 Global Color Table
FF 00 00
00 00 01
FF FF FF
00 00 FF

i presume those are my 5 colors(r,g,b,bk,wh), so my 10x10 image3 i think is green, so it should expand to all 5's, 2's or 1's
or

10 lines of that 10greens, or 105?

it will be easy to tell since the 10X10 image is unicolor, so the output chart will be the same # over.....

09 08 BA DC FE 30 CA 49 6B 4C <------------that is defiantly the image3 though.
 
hey that could work too, but i didnt know bitmaps were animated.... i am going to be using similar to flash card, but instead an spi memory ic.,, 1or8mbit avail i think,
 
I've just had a quick search - I've actually got TWO books :D

One is Bit-Mapped Graphics (2nd Edition) by Steve Rimmer, it has a chapter on GIF decoding, and one on encoding. If you can find a copy it should do all you want.

The second is about programming the hardware, and doesn't seem to give file formats.
 
Status
Not open for further replies.

Latest threads

Back
Top