GIF Decoder (SZW Compression)

This is a discussion on GIF Decoder (SZW Compression) within the C Programming forums, part of the General Programming Boards category; I can find the image block in GIF file and the tabular data block it gives me the byte size ...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    134

    GIF Decoder (SZW Compression)

    I can find the image block in GIF file and the tabular data block it gives me the byte size as 254 after that i must have SZW compressed data(pixel information) where i get 128, the table size is 128 i. th index must fall between 0-127(inclusive), the minimum bit to represent initial character is given 7.


    the coded data is like 128,0,3,5,4.........

    128 is unexpected i guess...

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Huh!?

    What's your question exactly?

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    134

    sorry if i could not make myself clear

    SZW coded code is 128,0,3,4,5.....
    and the initial representetion of character is of 7 bit...

    is it possible to have 128 at the first position?

  4. #4
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    A character is 7bits as per the original ASCII standard yes, the 8th bit was used for parity checking -- no longer the case (I think ) hence the set has been extended & you can use the 8th bit.

    Unsigned that means you can represent, (2^8) - 1 = 0 to 255 inclusive (unsigned) and -128 to 127 signed (-2^7 to 2^7 - 1). That's assuming CHAR_BITS = 8

    BTW, what is SZW compression!? Do you mean LZW?

    Quote Originally Posted by Dr. Dobb's Journal (LZW Fundamentals)
    The code that the LZW algorithm outputs can be of any arbitrary length, but it must have more bits in it than a single character. The first 256 codes (when using eight bit characters) are by default assigned to the standard character set. The remaining codes are assigned to strings as the algorithm proceeds. The sample program runs as shown with 12 bit codes. This means codes 0-255 refer to individual bytes, while codes 256-4095 refer to substrings.
    Last edited by zacs7; 05-14-2008 at 05:31 AM.

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    134
    yes i meant LZW

  6. #6
    Registered User
    Join Date
    May 2008
    Posts
    134

    again disturbing you

    there can be only 128 diffrent characters in the original file but when we use the compression technique we can have any character excluding the initial set of characters.. lets represent like this


    original file contains character having represented by 7 bit but what i m getting at 1st postion is 128 which needs 8 bits to represent, my question is any szw coded data may start with any character not belonging to the original set of characters..


    I have seen many lzw compressed data, all starts with the original text...
    M I Right?

  7. #7
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    Quote Originally Posted by kapil1089thekin View Post
    there can be only 128 diffrent characters in the original file but when we use the compression technique we can have any character excluding the initial set of characters.. lets represent like this


    original file contains character having represented by 7 bit but what i m getting at 1st postion is 128 which needs 8 bits to represent, my question is any szw coded data may start with any character not belonging to the original set of characters..


    I have seen many lzw compressed data, all starts with the original text...
    M I Right?
    You've acknowledged that you mean LZW, but then said szw again. There is no such thing.

    You seem to have described that the LZW compression tree starts with only 0-127 in it and thus the first code contains 7 bits and the next 128 subsequent codes contain 8 bits, then codes of length 9 begin.
    It would therefore be impossible to read in a code of 128 for the first value. You're only supposed to read in 7 bits for the first value, and you can't get 128 out of 7 bits, so clearly you are incorrectly reading 8 bits.
    Show your code.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. lzw decompressor (Gif Decoder) algorithm
    By kapil1089thekin in forum C Programming
    Replies: 1
    Last Post: 05-17-2008, 01:22 PM
  2. Data Compression
    By Ezerhorden in forum C++ Programming
    Replies: 5
    Last Post: 02-11-2006, 09:19 AM
  3. compression
    By X PaYnE X in forum C Programming
    Replies: 20
    Last Post: 01-11-2005, 04:14 PM
  4. efficient compression algorithm pls
    By gooddevil in forum C Programming
    Replies: 7
    Last Post: 05-08-2004, 03:33 AM
  5. Displaying a transparent gif
    By Just in forum Windows Programming
    Replies: 2
    Last Post: 05-09-2003, 09:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21