peraino@gmu90x.gmu.edu (peraino) (02/18/90)
Here is a screen compression/decompression routine which I whipped up back in early 1988. This one is better because it will also remove dark as well as white bytes. The code is small, tight, and fast enough. I played with doing RLE compression at the bit level, but it was very slow, and the results weren't all that great. I'll be doing more research on this in the future. I'm working with a new algorithm. LCDP Packs a screen. Just put it on the stack. LCDP counts a string of 0's, and prefixes the count by a zero. 255's are counted, and prefixed by 255. The image of SIN(x)=COS(x) (with axis and RAD mode) can be packed down to 380 bytes in 35 seconds. LCDP - LCD display string image compressor. Version 1.0 LCD-> string : Compressed image Method: Removed areas of all black or all white. CHK[607] << -> s ; Get image. << "" 1 548 ; Set up loop. FOR i ; Loop through bytes. s i i SUB DUP NUM ; Get byte. IF DUP 0 SAME SWAP 255 SAME OR THEN ;+-If 0 or 255, -> t ;| save. << t + 1 ;| Add prefix to output string. WHILE s OVER i + DUP SUB t SAME ;|+-While each consecutive OVER 255 <> AND REPEAT ;|| byte is the same, 1 + ;|| Keep a count. END ;|+-Endwhile- end of >> ;| end of run-length. SWAP OVER CHR + SWAP ;| Add count to output string. ELSE ;|-Else + 1 ;| Just add byte to output. END ;+-Endif STEP ; Get next byte. >> ; >> ; That's all, folks... XLCDP will uncompress a compressed image. The image of SIN(x)=COS(x) can be unpacked in 30 seconds. XLCDP - Uncompress screen image. Version 1.0 Compressed image string : LCD image string CHK[1518] << -> s ; Get compressed string. << "" 1 s SIZE ; Calc size. FOR i ;+-Loop through bytes. s i i SUB DUP NUM ;| Extract byte. IF DUP 0 SAME SWAP 255 SAME OR THEN ;|+-If 0 or 255, -> t ;|| Get value. << 1 s i 1 + DUP SUB NUM ;|| Get next byte- count. START ;||+-Loop required count. t + ;||| Add byte. NEXT ;||+-Add next. 2 ;|| Skip 2 bytes. >> ;|| ELSE ;||-Else + 1 ;|| Just add byte- skip 1. END ;|+-Endif STEP ;+-Get next byte. >> ; >> ; That's all, folks... ----------------------------------------------------------------------------- Bob Peraino UUCP : uunet!pyrdc!gmu90x!peraino George Mason University INTERNET: peraino@gmuvax.gmu.edu UCIS, Thompson Hall, rm 2 <- BITNET : peraino@gmuvax 4400 University Drive \ PHONE : (703)-323-2549 Fairfax, VA 22030 \- Yeah, they put us in the basement, too. -----------------------------------------------------------------------------
Jake-S@cup.portal.com (Jake G Schwartz) (02/20/90)
Regarding screen or any general string compression routines, I have a ques- tion for the group: Wouldn't there be an advantage to a compression tech- nique which would search for ANY repeating byte for say, six or more repeats in a row? This would squeeze anything down, including 'white' and 'black' bytes. Just a thought. Jake Schwartz
peraino@gmu90x.gmu.edu (peraino) (02/22/90)
>From Jake-S@cup.portal.com Mon Feb 19 18:42:12 1990 >Subject: Re: New screen compression routines. > >Regarding screen or any general string compression routines, I have a ques- >tion for the group: Wouldn't there be an advantage to a compression tech- >nique which would search for ANY repeating byte for say, six or more repeats >in a row? This would squeeze anything down, including 'white' and 'black' >bytes. Just a thought. > >Jake Schwartz Doing all bytes makes the Run Length prefix much more complicated, which adds to the overhead in the output file. If repeats of other types of bytes were common, it might pay off. But in practice, repeats, at the byte level, of anything except all black or white, are not common. I am working with a new algorithm which may give us a really great screen compressor. It will be at the expense of speed, but the results will be so good, no one will use the RLE based ones again. ----------------------------------------------------------------------------- Bob Peraino UUCP : uunet!pyrdc!gmu90x!peraino George Mason University INTERNET: peraino@gmuvax.gmu.edu UCIS, Thompson Hall, rm 2 <- BITNET : peraino@gmuvax 4400 University Drive \ PHONE : (703)-323-2549 Fairfax, VA 22030 \- Yeah, they put us in the basement, too. -----------------------------------------------------------------------------