arenberg@trwrb.UUCP (Jeff Arenberg) (05/10/88)
I am getting extremely frustrated trying to figure out how the properly use the Palette Manager. I have an image that I want to display with specific colors. Here is the approach I've been trying : 1. Init my own cGrafPort and allocate a color table for 256 entries. 2. Set the first entry to white, the second to black, and the remaining to the colors I want. 3. Read my temp file which has 12 bits of RGB data per pixel and set the pixels in my cGrafPort using SetCPixel. 4. Open a cWindow. Create a PaletteHandle for 256 colors. 5. Copy my color table to the palette using CTab2Palette and attach the palette to the window. 6. Use CopyBits to copy from the cGrafPort to the cWindow the first time and to update the window. When I do this, the colors come out all wrong. It looks like index values in the window are pointing to the wrong values in the screen color table. I've looked at the screen CLUT using the Klutz DA and most of the correct colors seem to be present. I don't understand why this approach fails. Does anyone have any working code that uses the Palette Manager and offscreen pixmaps? I know Giffer 1.0 handles palettes correctly, so it's not a hardware problem. I've running on a Mac II, 5 Meg, System 4.2, Finder 6.0, code is written in LSC. Any help is really appreciated. Jeff Arenberg ------------------------------------------------------------ UUCP : ( ucbvax, ihnp4, uscvax ) !trwrb!trwcsed!arenberg ARPA : jarenberg@ecla.usc.edu GEnie: shifty ------------------------------------------------------------
edmoy@violet.berkeley.edu (05/13/88)
In article <793@trwcsed.trwrb.UUCP> arenberg@trwcsed.UUCP (Jeff Arenberg) writes: > >I am getting extremely frustrated trying to figure out how the properly >use the Palette Manager. I have an image that I want to display with >specific colors. Here is the approach I've been trying : > . . . >6. Use CopyBits to copy from the cGrafPort to the cWindow the first time > and to update the window. > >When I do this, the colors come out all wrong. It looks like index values >in the window are pointing to the wrong values in the screen color table. I've been trying to get the Palette manager to work myself. The problem seem to be that CopyBits() does not cause the window's palatte to change, at least not entirely. In my test program, I try to draw the color spectrum (from violet to red) using the Color manager and it works fine. Converting to the Palette manager, I usually get random patterns of black and white stripes. If I make the CLUT of the pixmap point to the device's CLUT, I get the spectrum with several black stripes running through it at various places. I finally used FillRect to draw all the colors to the window, then do the CopyBits(). It looked like the FillRect() caused the palette to change correctly. I got a clean spectrum. The problem that remains is that apparently, even if the pixmap and palette use the same colors, CopyBits() does an inverse mapping and then a forward mapping. Probably due to the limitations in the standard inverse mapping algorithm, truncation occurs and I don't get all the colors I should. This occurs because in a spectrum, each color is close to its two neighboring colors, and so it selects the wrong one too often. For more random colors, you may not notice this problem. Edward Moy Workstation Software Support Group University of California Berkeley, CA 94720 edmoy@violet.Berkeley.EDU ucbvax!violet!edmoy