We Now Serve All Depths #

I've cleaned up the implementation a bit, and added proper hit testing. Now you can select and view all the depths & sizes of an icon. I've also implemented the pop-up menu to the top of the display, which lets you toggle between the depths. However you can only edit the 32 bit ones, since I haven't done the SetPixel8/4/1 functions yet.

(a bit later)

I've implemented a SetPixel8 function. It's pretty interesting. It receives an RGBColor as a parameter, but and 8 bit image is made up char's, which represent indexes in a color lookup table. So I wrote another function, GetColorIndex, which takes an RGBColor and a color table as parameters and returns the index of the closest color. To get the closest color I loop thru the color table, and add up the absolute values of the differences of the red, green and blue components. The smallest difference is the closest color. I guess that algorithm would work for 4 bit and 1 bit colors too, except setting the pixel is more tricky since i have to work with a nibble and a bit respectively, so it'll involve masking & shifting...but that can be done tomorrow...

Post a Comment