BBS: Inland Empire Archive Date: 11-23-92 (22:39) Number: 283 From: RICH GELDREICH Refer#: NONE To: HARVEY PARISIEN Recvd: NO Subj: A Gif decoder/p2 Conf: (2) Quik_Bas
<<Part 2 Starts Here>> X = X + 1: IF X = XEnd THEN GOSUB NextScanLine NEXT IF NextCode < 4096 THEN Prefix(NextCode) = LastCode Suffix(NextCode) = LastPixel NextCode = NextCode + 1 IF NextCode > MaxCode AND CodeSize < 12 THEN CodeSize = CodeSize + 1 MaxCode = MaxCode * 2 + 1 END IF END IF LastCode = Code END IF END IF LOOP UNTIL DoneFlag OR Code = EOSCode BEEP A$ = INPUT$(1) END GetByte: A$ = " ": GET #1, , A$: A = ASC(A$): RETURN NextScanLine: IF Interlaced THEN Y = Y + PassStep IF Y >= YEnd THEN PassNumber = PassNumber + 1 SELECT CASE PassNumber CASE 1: Y = 4: PassStep = 8 CASE 2: Y = 2: PassStep = 4 CASE 3: Y = 1: PassStep = 2 END SELECT END IF ELSE Y = Y + 1 END IF X = XStart: Ybase = Y * 320&: DoneFlag = Y > 199 RETURN GetCode: IF BitsIn = 0 THEN GOSUB ReadBufferedByte: LastChar = A: BitsIn = 8 WorkCode = LastChar \ ShiftOut(BitsIn) DO WHILE CodeSize > BitsIn GOSUB ReadBufferedByte: LastChar = A WorkCode = WorkCode OR LastChar * Powersof2(BitsIn) BitsIn = BitsIn + 8 LOOP BitsIn = BitsIn - CodeSize Code = WorkCode AND MaxCode RETURN ReadBufferedByte: IF BlockPointer > BlockSize THEN GOSUB GetByte: BlockSize = A A$ = SPACE$(BlockSize): GET #1, , A$ BlockPointer = 1 END IF A = ASC(MID$(A$, BlockPointer, 1)): BlockPointer = BlockPointer + 1 RETURN <<-Cut Here->> There you go! This is a more efficient version of my first GIF decoder... It can decode 320x200x256 GIFs at an acceptable speed(MUCH faster than my original decoder), but there are still a few optimizations I left out to keep it simple. Rich --- MsgToss 2.0b * Origin: Computer Co-Op - Voorhees, NJ | Ted Hare (1:266/29)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET