Path: utzoo!utgpu!water!watmath!clyde!bellcore!tness7!killer!mit-eddie!husc6!endor!olson From: olson@endor.harvard.edu (Eric K. Olson) Newsgroups: comp.sys.mac.programmer Subject: Re: Utilities for RGB to 8-Bit Message-ID: <4647@husc6.harvard.edu> Date: 24 May 88 18:47:19 GMT References: <92@ai.etl.army.mil> <6604@cit-vax.Caltech.Edu> <2863@polya.STANFORD.EDU> Sender: news@husc6.harvard.edu Reply-To: olson@endor.UUCP (Eric K. Olson) Organization: Lexington Software Design, Lexington, MA Lines: 43 In a recent article Marc T. Kaufman writes: >In article <6604@cit-vax.Caltech.Edu> wetter@tybalt.caltech.edu.UUCP (Pierce T. Wetter) writes: > >-> I have a 24-bit color image on VAX with UNIX: >-> I want to display this on Mac II, 8-bit video. > >> Sure, get one pixel at a time from your unix file, then SetRGBColor to >> red*256, green*256, blue*256, then SetPixel(x,y). This saves programmer time >> at the expense of user time. > >You might prefer SetCPixel, which does both operations at once. Both these techniques use the current ITable (Inverse Color Mapping Table), which is only 4 bits each of Red, Green, and Blue. To get slightly better results, you can use MakeITable() to get 5 bits each (for a total of 15 bits of inverse mapping). But you still don't get the best colors, and you don't get a color table chosen to match the data. If you are willing to settle for 5-bit ITable quality, you can create 3 off-screen PixMaps, with cluts set to Red, Green, or Blue ramps, fill them with the raw 8-bit data, and CopyBits them into a fourth PixMap with a transfer mode of AddPin. This takes about 5 seconds for a 640 X 480 pixel image. You can also then vary the color balance just by changing the cluts of the color planes. The best technique is to histogram the input data, choose 256 popular colors from the histogram, and match the 24-bit data into the color table exactly (it helps in terms of speed if the color table is sorted, so you don't have to compare to every entry). You can also dither the 24 bits into the color table. Finally, SuperMac Software, the makers of PixelPaint, have a software package that does all this for you quickly, and I believe it's free. Their address is 295 North Bernardo Ave., Mountain View, CA 94043. You'll probably have to adapt the raw 24-bit file before that package will take it (I think its called "PixelScan"). -Eric Lexington Software Design: Tomorrow's Software Yesterday Eric K. Olson olson@endor.harvard.edu harvard!endor!olson D0760 (Name) (ArpaNet) (UseNet) (AppleLink)