Path: utzoo!mnetor!uunet!oddjob!ncar!ames!eos!labrea!polya!kaufman From: kaufman@polya.STANFORD.EDU (Marc T. Kaufman) Newsgroups: comp.sys.mac.programmer Subject: Re: Choosing closest-color-by-blending Message-ID: <2578@polya.STANFORD.EDU> Date: 9 Apr 88 02:21:50 GMT References: <3184@coherent.com> Reply-To: kaufman@polya.stanford.edu (Marc T. Kaufman) Distribution: comp Organization: Stanford University Lines: 41 Keywords: RGB blending PixPat In article <3184@coherent.com> dplatt@coherent.com (Dave Platt) writes: .I'm working on a Mac II application that draws on the screen in color. .Currently, the colors are program-specified, but I plan to add a Color .Picker routine to permit the user to choose any of the colors supported .by Color QuickDraw. .I'd like to be able to generate reasonably-accurate hardcopy printouts .of the screen, using an ImageWriter II with a color ribbon. The IW II .supports the old-style Macintosh color model (8 specific colors, .including black and white), but the printer driver doesn't know how to .map Color QuickDraw 48-bit color specifications into the 8-color .model. . The Mac II's Color QuickDraw supports a .technique like this for drawing within a color window; one supplies an .(R,G,B) color as input, and receives in return a colored "brush" (a .pattern of 8*8 pixels). Within the "brush", each 2*2 square of pixels .can combine up to 4 of the colors available in the window's color .table, with the "average" color falling reasonably close to the (R,G,B) .input color. .Unfortunately, this capability necessitates that one have a window .available whose color table contains only those colors actually .available for drawing. Printing isn't performed via a color window... .it uses an old-style 1-bit-deep GrafPort, and the Color QuickDraw .routines won't work with it. So, I'll need to construct such a colored .brush myself. Try the following: Draw into an offscreen PixMap, using 8 colors (the imagewriter CLUT) in a 4-bit deep Map. While the offscreen device is active, let Quickdraw generate the color pixpat, using the CLUT you have provided. This should yield 4-bit pixels with one bit each of R,G,B (and one bit unused). Save this PixMap, and scan it to the Imagewriter driver, doing a SetForeColor every time the pixel value changes. (grubby, but it probably will work). [I posted this to mac.programmer only, as the comp.graphics people probably have a better way :-)] Marc Kaufman (kaufman@Polya.stanford.edu)