essentially i want to do a gif decoder however i need to do myown code so i have been looing in to gif files and as far as i see they are usually compressed in an 89a format, is this the universal default?
so far i have been able to extract all the header info, and color tables, but when it comes to the image compression i am stumped, even after reading the 50 tutorials out there.
i am lead to understand that the file is stored under lzw compession, can someone walk me through step by step how to decode a small line, i dont need it in code or anything, i just cant understand how the cycle works..... the tutorials also confuse me with 9-bit encoding how does that fit in? do most gif files do this???
my other question is after the decompression i am lead to believe that the gif code for my 10 x 10 pixle black square
will be like this(presuming black is 5):
5555555555 = 10 fives,
is that how the hex syntax would look for line 1: 10 05 ?????
Can't answer you, but I believe you've just described a weak, lossless format called run-length encoding... A compression as complex as lzw involves some serious mathematic formulae. I hope that a wizard here can help you. Such methods tend to be carefully guarded or legally protected secrets. People tend to use compression 'codecs' for such things since nobody has to know how the black box works. I hope this puts things into perspective. Such code might be outside the scope of an amateur unfamiliar with strong math to comprehend I think... I wish you good fortune in your endeavor since if you do understand the results tend to become more publicly available and get improved upon thus. As it should be with such an old graphics format. They should open it up since it works so well. But companies hold on to such things like grim death, and I've seen folks get sued and the like... Sad. There are windows API functions that your application can make use of to utilize .gif files very effectively, but they won't open the black box up. I have a good library function I got somewhere for VB6 if you'd like it, here it is.
You might have examined it already, it utilizes the OleLoadPicture function in olepro32.dll to decompress the frames of a gif file.
Last edited by mikorians; Oct 9th, 2012 at 09:37 PM.
I include a simple LZW compression application. This is used on text strings. It is not exactly the same LZW that is used in Gif images but the principal is the same. If you can understand the code as to how it works for string data maybe you might be able to use this code with modifications for the Gif data compressed image bytes.
Last edited by jmsrickland; Oct 10th, 2012 at 08:22 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
I found this on the Net, unfortunately, it was written in Java. I know a little about Java so I did my best to translate it into VB6. I used a 1-pixel gif image that I made for testing. I ran it but I didn't see where it did anything but that could be because my translation is not 100% correct or I don't know what to look for or the original Java didn't work in the first place.
To run this code, you first need to read in a Gif file into a byte array and set the byte pointer to the correct byte in the array. The first set of code reads the gif file into a byte array and sets the byteIndex pointer to the correct byte then it calls a sub to initialize some variables then it calls the sub to decode the Images data. You will probably need to set the ByteIndex to where ever that byte is in your array.
The second set of code is the actual LZW Java code I translated into VB6.
First set - Form Code
Code:
Private Sub cmdCall_decodeImageData_Click()
Open App.Path & "\1 pixel red image.gif" For Binary As #1
ReDim fileBytes(0 To LOF(1) - 1)
Get #1, , fileBytes
Close #1
byteIndex = 782 ' Point to image X position in array
'
' +-- 782 +------------ 791 = start of LZW Data
' | = X position of image |
' | |
' | X Y W H CT |
' 2C | 00 00 | 00 00 | 01 00 | 01 00 | 40 | 08 04 00 11 04 04 00 3B
' |
' |
' +-- 781
retrieveImage ' initalize rect array with X, Y, W, H of image
decodeImageData ' decode the image data
End Sub
The next set is too big so I have to post it in two more posts after this one. Just copy each post and put them im a module.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Const ERROR_NONE = 0 ' public static final int ERROR_NONE = 0;
Const ERROR_OPEN = 1 ' public static final int ERROR_OPEN = 1;
Const ERROR_READ = 2 ' public static final int ERROR_READ = 2;
Const ERROR_FORMAT = 3 ' public static final int ERROR_FORMAT = 3;
Private errorCode As Integer ' private int errorCode;
Const MaxStackSize = 4096 ' private static final int MaxStackSize = 4096;
Public fileBytes() As Byte ' private byte[] fileBytes;
Public byteIndex As Long ' private int byteIndex = 0;
Private block(256) As Byte ' private byte[] block = new byte[256];
Private blockSize As Integer ' private int blockSize = 0;
Private rect(4) As Integer ' private int[] rect = new int[4];
Private lastRect As Integer ' private int[] lastRect;
Private prefix() As Integer ' private short[] prefix;
Private suffix() As Byte ' private byte[] suffix;
Private pixelStack() As Byte ' private byte[] pixelStack;
Private pixels() As Byte ' private byte[] pixels;
' '/**
' Checks for errors and prints out a message ' * Checks for errors and prints out a message
' if any occurred ' * if any occurred
' return False if there were no errors ' * @return False if there were no errors.
' ' */
Private Function checkError() As Boolean 'public boolean checkError(){
Select Case errorCode ' switch( errorCode ){
Case ERROR_NONE ' case ERROR_NONE:
checkError = False ' return false;
Case ERROR_OPEN ' case ERROR_OPEN:
checkError = True ' return true;
Case ERROR_READ ' case ERROR_READ:
checkError = True ' return true;
Case ERROR_FORMAT ' case ERROR_FORMAT:
checkError = True ' return true;
Case Default ' default:
checkError = True ' return true;
End Select ' }
End Function '}
' '/**
' The next byte will be retireved from the ' * Retrieves the next byte of data.
' array that the GIF file was read into ' * @return -1 if end of buffer was reached.
' ' */
Private Function nextByte() As Byte 'Integer 'private int nextByte(){
If byteIndex >= UBound(fileBytes) Then ' if( byteIndex >= fileBytes.length )
nextByte = -1 ' return -1;
Exit Function
End If
Dim curByte As Byte ' byte curByte = fileBytes[ byteIndex ];
curByte = fileBytes(byteIndex)
byteIndex = byteIndex + 1 ' byteIndex++;
nextByte = curByte And &HFF ' return curByte & 0xFF;
End Function '}
' '/**
' Retrieves the next 16-bit value ' * Retrieves the next 16-bit value.
' Returns two bytes of data ' * @return Two bytes of data.
' ' */
Private Function retrieveShort() As Integer 'Byte 'private int retrieveShort(){
Dim b1 As Byte
Dim b2 As Byte
b1 = nextByte()
b2 = nextByte()
retrieveShort = b2 * 256 + b1 ' return nextByte() | ( nextByte() << 8 );
End Function '}
' '/**
' Retrieves a GIF data block and returns it's size ' * Retrieves a GIF data block and returns its size in bytes.
' in bytes - return Number of bytes retrieved ' * @return Number of bytes retrieved.
' ' */
Private Function retrieveBlock() As Integer 'private int retrieveBlock(){
Dim x As Integer
Dim i As Integer
blockSize = nextByte() ' blockSize = nextByte();
If blockSize > 0 Then ' if( blockSize > 0 )'{
x = 0 ' int x = 0;
i = -1 ' int i = -1;
For x = 0 To blockSize - 1 ' for( x = 0; x < blockSize; x++ )'{
i = nextByte() ' i = nextByte();
If i = -1 Then ' if( i == -1 )
Exit For ' break;
End If
If x < UBound(block) Then ' if( x < block.length )
block(x) = CByte(i) ' block[x] = (byte) i;
End If
Next x ' }
If x < blockSize Then ' if( x < blockSize )
errorCode = ERROR_FORMAT ' errorCode = ERROR_FORMAT;
End If
If blockSize > UBound(block) Then ' if( blockSize > block.length ){
blockSize = UBound(block) ' blockSize = block.length;
End If ' {
End If ' {
retrieveBlock = blockSize ' return blockSize;
End Function '}
' '/**
' Retrieves and decodes image data ' * Retrieves and decodes image data.
' ' */
Public Sub retrieveImage() 'private void retrieveImage(){
Dim packed As Byte
'
' Sub-image position and dimensions ' // sub-image position and dimensions:
'
rect(0) = retrieveShort() ' rect[0] = retrieveShort();
rect(1) = retrieveShort() ' rect[1] = retrieveShort();
rect(2) = retrieveShort() ' rect[2] = retrieveShort();
rect(3) = retrieveShort() ' rect[3] = retrieveShort();
packed = nextByte() ' int packed = nextByte();
End Sub '{
Last set in next post
Last edited by jmsrickland; Oct 12th, 2012 at 08:45 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
' '/**
' Decodes LZW image data into the pixel array ' * Decodes LZW image data into the pixel array.
' ' */
Public Function decodeImageData() 'private void decodeImageData(){
Dim NullCode As Integer
NullCode = -1 ' int NullCode = -1;
Dim npix As Integer
' W H
npix = rect(2) * rect(3) ' int npix = rect[2] * rect[3];
Dim available As Integer ' int available, clear, code_mask, code_size, end_of_information, in_code, old_code, bits, code, count, i, datum, data_size, first, top, bi, pi;
Dim clear As Integer
Dim code_mask As Integer
Dim code_size As Integer
Dim end_of_information As Integer
Dim in_code As Integer
Dim old_code As Integer
Dim bits As Integer
Dim code As Integer
Dim count As Integer
Dim i As Integer
Dim datum As Integer
Dim data_size As Integer
Dim first As Integer
Dim top As Integer
Dim bi As Integer
Dim pi As Integer
If isArrayEmpty(pixels) Then ' if( ( pixels == null ) || ( pixels.length < npix ) ){
ReDim pixels(npix)
Else
If UBound(pixels) < npix Then
ReDim pixels(npix)
End If ' }
End If
If isArrayEmpty(prefix) Then ' if( prefix == null )
ReDim prefix(MaxStackSize) ' prefix = new short[ MaxStackSize ];
End If
If isArrayEmpty(suffix) Then ' if( suffix == null )
ReDim suffix(MaxStackSize) ' suffix = new byte[ MaxStackSize ];
End If
If isArrayEmpty(pixelStack) Then ' if( pixelStack == null )
ReDim pixelStack(MaxStackSize + 1) ' pixelStack = new byte[ MaxStackSize + 1 ];
End If
'
'
' Initalize GIF data stream decoder ' // Initialize GIF data stream decoder:
'
data_size = nextByte() ' data_size = nextByte();
clear = 1 * 2 ^ data_size ' clear = 1 << data_size;
end_of_information = clear + 1 ' end_of_information = clear + 1;
available = clear + 2 ' available = clear + 2;
old_code = NullCode ' old_code = NullCode;
code_size = data_size + 1 ' code_size = data_size + 1;
code_mask = (1 * 2 ^ code_size) - 1 ' code_mask = ( 1 << code_size ) - 1;
For code = 0 To clear - 1 ' for( code = 0; code < clear; code++ ){
prefix(code) = 0 ' prefix[ code ] = 0;
suffix(code) = CByte(code) ' suffix[ code ] = (byte) code;
Next code ' }
'
' Decode GIF pixel stream ' // Decode GIF pixel stream:
'
datum = 0: bits = 0: count = 0: first = 0: top = 0: pi = 0: bi = 0 ' datum = bits = count = first = top = pi = bi = 0;
For i = 0 To npix - 1 ' for( i = 0; i < npix; ){
If top = 0 Then ' if( top == 0 ){
If bits < code_size Then ' if( bits < code_size ){
'
' Load bytes until there are enough bits for a code ' // Load bytes until there are enough bits for a code:
'
If count = 0 Then ' if( count == 0 ){
'
' Read a new data block ' // Read a new data block:
'
count = retrieveBlock() ' count = retrieveBlock();
If count <= 0 Then Exit For ' if( count <= 0 ) break;
bi = 0 ' bi = 0;
End If ' }
' datum is Integer block is Byte
datum = datum + (CInt(block(bi)) And &HFF) * 2 ^ bits ' datum += ( ( (int) block[ bi ] ) & 0xff ) << bits;
bits = bits + 8 ' bits += 8;
bi = bi + 1 ' bi++;
count = count - 1 ' count--;
GoTo NextIteration ' continue;
End If ' }
'
' Get the next code ' // Get the next code:
'
code = datum And code_mask ' code = datum & code_mask;
datum = datum / 2 ^ code_size ' datum >>= code_size;
bits = bits - code_size ' bits -= code_size;
'
' Interpret the code ' // Interpret the code:
'
If code > available Or code = end_of_information Then ' if( ( code > available ) || ( code == end_of_information ) )
Exit For ' break;
End If
If code = clear Then ' if( code == clear ){
'
' Reset decoder ' // Reset decoder
'
code_size = data_size + 1 ' code_size = data_size + 1;
code_mask = (1 * 2 ^ code_size) - 1 ' code_mask = (1 << code_size) - 1;
available = clear + 2 ' available = clear + 2;
old_code = NullCode ' old_code = NullCode;
GoTo NextIteration ' continue;
End If ' }
If old_code = NullCode Then ' if( old_code == NullCode ){
pixelStack(top) = suffix(code) ' pixelStack[top++] = suffix[ code ];
top = top + 1
old_code = code ' old_code = code;
first = code ' first = code;
GoTo NextIteration ' continue;
End If ' }
in_code = code ' in_code = code;
If code = available Then ' if( code == available )'{
pixelStack(top) = CByte(first) ' pixelStack[top++] = (byte) first;
top = top + 1
code = old_code ' code = old_code;
End If ' }
Do While code > clear ' while( code > clear )'{
pixelStack(top) = suffix(code) ' pixelStack[ top++ ] = suffix[ code ];
top = top + 1
code = prefix(code) ' code = prefix[ code ];
Loop ' }
first = CInt(suffix(code)) And &HFF ' first = ( (int) suffix[ code ] ) & 0xff;
'
' Add a new string to the string table ' // Add a new string to the string table:
'
If available >= MaxStackSize Then ' if( available >= MaxStackSize )
Exit For ' break;
End If
pixelStack(top) = CByte(first) ' pixelStack[ top++ ] = (byte) first;
top = top + 1
prefix(available) = old_code ' prefix[ available ] = (short) old_code;
suffix(available) = CByte(first) ' suffix[ available ] = (byte) first;
available = available + 1 ' available++;
If (available And code_mask) = 0 _
And available < MaxStackSize Then ' if(((available & code_mask) == 0) && (available < MaxStackSize))'{
code_size = code_size + 1 ' code_size++;
code_mask = code_mask + available ' code_mask += available;
End If ' }
old_code = in_code ' old_code = in_code;
End If ' }
'
' Retrieve next pixel from the stack ' // Retrieve next pixel from the stack:
'
top = top - 1 ' top--;
pixels(pi) = pixelStack(top) ' pixels[ pi++ ] = pixelStack[ top ];
pi = pi + 1
'NOT NEEDED IN VB-->i = i + 1 ' i++;
NextIteration:
Next i ' }
'
' Clear missing pixels ' // clear missing pixels:
'
For i = pi To npix - 1 ' for( i = pi; i < npix; i++ )
pixels(i) = 0 ' pixels[i] = 0;
Next i
End Function '}
Private Function isArrayEmpty(arr As Variant) As Boolean
'
' True it is empty, False it is not empty
'
Dim dblCount As Double
isArrayEmpty = True
On Error Resume Next
' causes an error if empty
dblCount = UBound(arr)
If Err.Number > 0 Then Exit Function
isArrayEmpty = False
End Function
Last edited by jmsrickland; Oct 12th, 2012 at 08:45 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
so far i have ripped a gif file to hex and been able to decode the following which is a 10x10 black square,then a10x10 blue square, hex looks like this:
47 49 46 38 39 61 // header gif type
0A 00 - logical screen width in pixels
0A 00 - logical screen height in pixels
99 - GCT follows for 256 colors with resolution 3 x 8 bits/primary
01 - background color #0
00 - default pixel aspect ratio
00 00 01 Global Color Table
00 00 FF
00 00 00
00 00 00
21 F9 - Graphic Control Extension
04 05 36 00 - 4 bytes of GCE data follow
02 - transparent background color
00 21 - delay for animation: not used
FF - color #ff is transparent
0B - end of GCE block
4E 45 54 53 43 41 50 45 32 2E 30 //netscape 2.0
03 -(hex 0x03) Length of Data Sub-BlocK (three bytes of data to follow)
01 - 1 (hex 0x01)
61 00 - LOOP INTEGER / BACKWARDS
00 - SUB BLOCK TERMINATOR
start of imagery
2C -Image Descriptor
00 00 00 00 - NW corner position of image in logical screen
0A 00 0A 00 - image width and height in pixels
00 - no local color table
-------------------------------------------------------------but--------------------------------------------------------
it is this line of compressed image data thats got me, since it is the first image it will be a 10x10 black square:
02 - Start of image - LZW minimum code size BLck
08 84 8F - 11 bytes of LZW encoded image data follow
A9 CB ED
0F 63 2B
00 sub block terminator in effect
first i am confused to how the output code will look, since black is color table 1, and image is 10x10, i have understood that output code will look like this
0A 01 0A 01 0A 01 0A 01
0A 01 0A 01 0A 01 0A 01
0A 01 0A 01
is that correct? ten pixles of 1's for each line, or should it be 64 01's(64 being hex100)?
i still dont see how
02 08 84 8F A9 CB ED 0F 63 2B 00
expands to 0a 01 0a 01 0a 01 0a 01 0a 01 0a 01 0a 01 0a 01 0a 01 0a 01
or 64 01,
ALSO i dont need code specifically i just need to figure out how to do it on paper, that is partial to why i kept my example gif so small
02 = Minimum Code Size
08 = Number of bytes of LZW
84 BF A9 CB ED 0F 63 2B = LZW Code
00 = Block Terminator
I realize you need a "paper written" explanation of how it works, rather than the code itself, but I just thought that if I could find some code for you that you might be able to see from the code what the steps are you need to take.
I do not know what the expected output of decoding LZW is supposed to look like so I can't tell you if your above question is on the right track or not. I will look further into this as I myself would like to know how it works. Are you 100% sure that your color black is position 1 in the color table? How do you know this? Can you post your gif file for me to take a look at?
Did you try that example I posted?
Last edited by jmsrickland; Oct 13th, 2012 at 09:56 AM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
so far i have ripped a gif file to hex and been able to decode the following which is a 10x10 black square,then a10x10 blue square, hex looks like this:
47 49 46 38 39 61 // header gif type
0A 00 - logical screen width in pixels
0A 00 - logical screen height in pixels 99 - GCT follows for 256 colors with resolution 3 x 8 bits/primary 01 - background color #0
00 - default pixel aspect ratio
00 00 01 Global Color Table
00 00 FF
00 00 00
00 00 00
21 F9 - Graphic Control Extension
04 05 36 00 - 4 bytes of GCE data follow 02 - transparent background color
00 21 - delay for animation: not used FF - color #ff is transparent
0B - end of GCE block
4E 45 54 53 43 41 50 45 32 2E 30 //netscape 2.0
03 -(hex 0x03) Length of Data Sub-BlocK (three bytes of data to follow)
01 - 1 (hex 0x01)
61 00 - LOOP INTEGER / BACKWARDS
00 - SUB BLOCK TERMINATOR
start of imagery
2C -Image Descriptor
00 00 00 00 - NW corner position of image in logical screen
0A 00 0A 00 - image width and height in pixels
00 - no local color table
-------------------------------------------------------------but--------------------------------------------------------
it is this line of compressed image data thats got me, since it is the first image it will be a 10x10 black square:
02 - Start of image - LZW minimum code size BLck
08 84 8F - 11 bytes of LZW encoded image data follow
A9 CB ED
0F 63 2B
00 sub block terminator in effect
first i am confused to how the output code will look, since black is color table 1, and image is 10x10, i have understood that output code will look like this
0A 01 0A 01 0A 01 0A 01
0A 01 0A 01 0A 01 0A 01
0A 01 0A 01
is that correct? ten pixles of 1's for each line, or should it be 64 01's(64 being hex100)?
i still dont see how
02 08 84 8F A9 CB ED 0F 63 2B 00
expands to 0a 01 0a 01 0a 01 0a 01 0a 01 0a 01 0a 01 0a 01 0a 01 0a 01
or 64 01,
ALSO i dont need code specifically i just need to figure out how to do it on paper, that is partial to why i kept my example gif so small
You have a few things not quite right.
1) 99 - GCT follows for 256 colors with resolution 3 x 8 bits/primary
the color table is not 256 colors. The color table only has 4 colors
2) 01 - background color #0
the value is not the color. It is the Index to the color. So, if the value is 01 then it is color 01 in the color table and from your description of the color table color index 1 is 00 00 FF which is blue.
3)
00 00 01 Global Color Table
00 00 FF
00 00 00
00 00 00
The 1st color is 00 00 01 which is almost black
The 2nd color is 00 00 FF which is blue
The 3rd and 4th colors are 00 00 00 which is black
4)
21 F9 - Graphic Control Extension
04 05 36 00 - 4 bytes of GCE data follow
02 - transparent background color
00 21 - delay for animation: not used
FF - color #ff is transparent
0B - end of GCE block
The above is read like this:
21 F9 - Graphic Control Extension
04 - 4 bytes of data to follow
05 - contains the Disposal value
36 00 - Delay
02 - transparent color index (not transparent background color)
00 - block terminator
21 FF - Application extension
0B - number of bytes to follow which is 11 and the bytes are NETSCAPE2.0
After the LZW code is decoded the output is a series of color indices one for each color pixel in the image.
Here I am using 02 because 02 is the index of the 3rd color in the color table which is black. The 1st color in the table is 00 00 01 which is not pure black. However, if that is the color being used then the output would be:
but I don't think so and also I have not seen any GIF where a color in the GIF image is at 0 of the color table.
Hopes this helps a little.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
that could be it, thnx, i have been following, gimmie a bit to get back with the ex file and my results, but i think you found my hump, also one more thing i want to make sure i understand correctly, is that:
if my minimum code size is 2 bits, with that table of four lines, does that mean i am to "shift out" the 2bits at a time from the lzw?
then if the dictionary needs to get bigger i start running it at 3 bits at a time?
02 - Start of image - LZW minimum code size BLck
08 84 8F - 11 bytes of LZW encoded image data follow
A9 CB ED
0F 63 2B
00 sub block terminator in effect
Are you sure you copied the code correctly? I ask because I am unable to uncompress this code. I made a 10 x 10 black GIF and I was able to expand the graphic data code but not using yours. I notice that your LZW code does not contain a CLEAR code which should be present in all LZW data.
EDIT:
Never mind above. I got it to work.
BTW: the output of the image data is 100 &H00
<---------------------------- 100 --------------------------------->
00 00 00 00 00 00 00 00 00 00 00 ....................... 00 00 00 00 00
Last edited by jmsrickland; Oct 21st, 2012 at 08:10 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
maybe i should have asked earlier, but my origional intention is to take a typical gif from the web and upload it to device, but anyway i found gif89a structures all over, so i hope i this is the norm filetype..?
the file was created with easy gif animator, and my bmp's were done in paint,
also i was unable to bring that code in to my vb6, (user error, i wasnt sure where to put thing on the form,, ie in form load, or general declerations, or on a button, but thats ok , \)
and you say that my output is 00 00 00 00 00 00.............00 since black is position 0 in the table(which is the firstone??)
but now back to this: 08 is just the code length, which helped alot!! and the bit size is only 2, so my first hex84 so 0b10000100
==
so first byte is 00, output, simple, but now i import next(2bit) byte, which is 01?? cant be thou, maybe i am suppost to shift it in by a bit, which would make it 0b010?
unless im mistaken and the color table starts at 1, and 00 is a default byte from earlier on?
also when we say clear code,we do mean clear as in transparent right?
Your text file is not correct. You need to go back and read post #10.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
looking at thread 10, i think i got most of it, some of that i simply compressed, you did mention my output was 00....00 were you able to note where in the color table that was, did it end up at 0 or 2?
/quote
02 - Start of image - LZW minimum code size BLck
08 84 8F - 11 bytes of LZW encoded image data follow
A9 CB ED
0F 63 2B
00 sub block terminator in effect
/quote
that is the part i really messed up, i think
EDIT:
02 - Start of image - LZW minimum code size BLck
08 - bytes in lzw
84 8F A9 CB ED 0F 63 2B - code
00 sub block terminator in effect
the bit size is only 2, so my first hex84 so 0b10000100
==
so first byte is 00, send to output,
but now i import next(2bit) byte, which is 01?? maybe i am suppost to shift it in by a single bit, or is it 2 bits at a time which would make it 0b010?
that is a 2 so output 2 then shift in 0, the next byte 100 which would be 4 on the color table which was added as two two's?
No, that is not how it works. You are not even close.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
edit..... actually you said you had a working project, any chance you could post the project?
Ummm. where did I say that?
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Actually at first I thought it didn't work but then after trying it a couple of times more I then though I did get it to work but then I realized it was outputting color index 0 as a default but it didn't really work. I have tried and tried many times using many different approaches and I still cannot get it to translate correctly. Now I do have some code that works for some gif images but only very simple ones like small, very few colors, and always must have a bit size of 8 and even then it doesn't work most of the time. It absolutely does not work when the gif has a bit size of 2 (like your 10 x 10 gif). I don't know yet exactly how to do this but I am working on it and little by little I'm getting closer to completely understanding the decoding algorithyms that I see on the Net but still I cannot get them to work most of the time so there must be something I am overlooking. You can try that code I posted and see what it does.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
..... i am stumped, even after reading the 50 tutorials out there.
Can you post some links to the tutorials you have read?
I have searched the net and found several (not 50 though) and from what I have read they are all pretty much saying the same thing. The psuedo-code examples given describe the very basic steps you need to go through.
Why don't you post a link to one of the ones you have seen and I will try to help you understand it.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
I have spent some time and effort on figuring out how to decode the GIF LZW image data in response to your 1st post and I have been successful in doing so. However, you don't seem to be interested in your request as you do not respond to my previous posts. Maybe you have resolved your problem or you have moved on to something else. That's OK. So, if I do not hear from you in the next couple of days I will dissolve my interest in this Thread and unsubscribe to it.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.