Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!ut-emx!walt.cc.utexas.edu!aceman From: aceman@walt.cc.utexas.edu (acy james stapp) Newsgroups: comp.graphics Subject: Re: Displaying 256 color GIFs on 16 color device Message-ID: <22099@ut-emx.UUCP> Date: 8 Dec 89 05:05:47 GMT References: <49396@bbn.COM> Sender: news@ut-emx.UUCP Reply-To: aceman@walt.cc.utexas.edu (acy james stapp) Organization: The University of Texas at Austin, Austin, Texas Lines: 49 In article <49396@bbn.COM> sminkin@BBN.COM () writes: >I've recently written a program to display GIF files on DEC VT340 >terminals using color sixel. The 16 color GIF files come out beutifully, >but I don't really have a scheme for converting 256 colors down to >16 (which is the limitation of the VT340). Is there a preferred Try this algorithm: read row(0) convert row(0) to array[length+1] of signed int; (or less, this is what I use) until eof() do read row(1) from file convert row(1) to array of int for every element of row(0) do newrow(element)=newrow(element)+(red>>7)>>3 row(0)(element+1)(red)=(red+1)>>1 row(1)(element)(red)=red>>1 newrow(element)=newrow(element)+(green>>6)<<1 row(0)(element+1)(green)=(green+1)>>1 row(1)(element)(green)=green>>1 newrow(element)=newrow(element)+(blue>>7) row(0)(element+1)(blue)=(blue+1)>>1 row(1)(element)(blue)=blue>>1 enddo write row(0) to file row(0)=row(1) /* HaHaHa to all you C programmers! Try doing this with one statement! */ enddo >> means shift into nothingness, << means shift into overflowingness use the following color map to display your final thingythingy Val R G B 0 0 0 0 1 0 0 255 2 0 85 0 3 0 85 255 4 0 170 0 5 0 170 255 6 0 255 0 7 0 255 255 8-15 255 as above-8 email me for an explanation if you're too stupid to figure it out yourself. <*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*> <*>Acy Stapp email: aceman@walt.cc.utexas.edu `NO SMOKING IN CORRIDORS' <*> <*>"Learn to love your anger now, anger here is all you posess" Duran Duran <*> <*>Disclaimer: The opinions presented above are true and correct, and if *>*<*> <*>**<*>*<*>*<*>*<*> <*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>*<*>