c60c-3fz@e260-3f.berkeley.edu (In Sik Rhee) (11/05/90)
After hacking away for 13 straight hours today, I finished my GifImp code finally... Surprise, surprise, the pre-release ships tomorrow (actually, today... yawn!). but I haven't quite perfected it, so I'm asking for some advice/tips/help... As I have it now, I am importing a GIF and creating a DIB (Device-Independant Bitmap) which, in turn, becomes a Metafile... now, the problem I face is that with a 256 color GIF image, I create a logical palette... but when I select and realize it, windows will not let me take precedence over its 20 primary colors in the system palette... so essentially, it will only give me 236 color indices... (or am I doing something wrong?) so for now, I am setting the last 20 colors the value of the 236th color (usually works out since most 256 color vga shots are digitized pics which have very close color values for closely mapped values) and you really cant tell the difference unless you looked for it. But I'm a purist, so I want to know how I can incorporate all my 256 colors (or as many as possible) for my application. I have one hypothesis that I think may work... In addition to selecting and realizing the logical palette, I can pass literal RGB values to the DIB instead of color indices... Wouldn't that give me the same results for the 236 colors already defined? and as for the last 20 colors, since windows palette manager will use a "best-match" algorithm, wouldn't they be mapped to the nearest possible pre-defined colors? so that way, instead of having them all be the 236th color, they'll be the closest color out of the 236 colors (+20 system colors) Can someone help me out? Am I making any sense? I'd like to get this problem solved so I can go onto bigger problems at hand (like trying to get Word for Windows and Microsoft PowerPoint to use my filter correctly) Thanks in advance for any comments... InSik Rhee
kensy@microsoft.UUCP (Ken SYKES) (11/07/90)
In article <1990Nov5.102146.27535@agate.berkeley.edu> c60c-3fz@e260-3f.berkeley.edu (In Sik Rhee) writes: >After hacking away for 13 straight hours today, I finished my GifImp code >Bitmap) which, in turn, becomes a Metafile... now, the problem I face is >that with a 256 color GIF image, I create a logical palette... but when >I select and realize it, windows will not let me take precedence over its >20 primary colors in the system palette... so essentially, it will only >give me 236 color indices... (or am I doing something wrong?) so for now, >I am setting the last 20 colors the value of the 236th color (usually works >out since most 256 color vga shots are digitized pics which have very close >color values for closely mapped values) and you really cant tell the >difference unless you looked for it. What you are doing is right except I don't understand what you mean by "filling the last 20 colors..." since the palette manager would map all those duplicate colors to the same system palette index anyways. > >But I'm a purist, so I want to know how I can incorporate all my 256 colors >(or as many as possible) for my application. > If you are a true purist then you should accept your current solution. The (should I say A) problem with the Mac is that the entire screen changes colors when you display a 256 color image. Some of the results can be quite disgusting looking. Windows reserves these twenty colors so it can guarantee accurate reproduction of dithers and standard solids. Now if you REALLY want all 256 colors you can get closer (254 of them) by using the SetSystemPaletteUse function to grab the entire palette. Windows will still keep two entries for black and white (necessary for proper operation.) See the Guide to Programming about how to use this function properly. Use of this function comes with certian responsibilities, the primary one being you will remember the system palette contents when you are activated and restore the system palette when deactivated. This ensures that other windows will be messed up ONLY when your app is in the foreground. Also keep in mind people may not like you making the rest of their screen ugly so have this as a menu option.