Re:Changing a single color on a bitmap palette
Quote
"Ed Dressel" <E...@brandentech.com> wrote in message
news:387A52D0.D9B50A6A@brandentech.com...
Quote
> I need to change a single color (clLime, shipped by us) on a bitmap
> palette to a different color (various, user selected depending on
> variables). When I have done this with a loop, it worked fine on my 64k
> color machine, but the colors were all wrong on a 256 color machine. So
> I figure that the palette is the problem. Is there any way of making
> sure that the colors I need are avaiable on the bitmap canvas?
What is the PixelFormat of your image? pf8bit or pf24bit?
How are you changing the color? Are you using the canvas.Pixels
property (which will be fairly slow), or are you changing the palette
and filling in the Scanlines?
Quote
> And, I was thinking that I should be able to just change the one color
> in the palette that I know needs to be changed, not have to loop through
> the whole canvas. Am I right? How would I do this?
While working on pf8bit scanline examples, described at
http://www.efg2.com/Lab/ImageProcessing/Scanline.htm, I observed
the only way I obtained reliable results was to set the palette for a new
bitmap and then fill in the scanlines. This is fairly fast using the
Scanline property.
I'm only guessing, but when you try to change a palette on a bitmap
and leave the scanlines untouched, Windows tries to find the "nearest"
color for you and can modify the scanline data as part of what it does.
I found I had to fill in the scanline data once the palette was set to
get reliable results.
For links about using palettes in Delphi, try Section A of
http://www.efg2.com/Lab/Library/Delphi/Graphics/Algorithms.htm
--
efg
Earl F. Glynn E-Mail: EarlGl...@att.net
Overland Park, KS USA
efg's Computer Lab: http://www.efg2.com/Lab