I have been experimenting with the Change HUE/Saturation
example found on the EFG website: http://www.efg2.com/Lab/Library/Delphi/Graphics/Color.htm
I want to use the techniques found in that example to change the color values of some bitmaps (to be used on a TImage). There is one problem I am facing, and that is with TImages that have transparent bitmaps; I don't want the background color to change its HUE but rather just the actual image data.
Take this sample image we can work with (though any image with transparency can be used):
- Download the
Change HUE/Saturation
demo from the link at the top. - Now Load the button image above into the ImageOriginal.
- Set the Delta Saturation to 1.
- Run the Project.
Some output results:
What I would like to happen here is keep the original background color (defined by the bottom left most pixel) and only adjust the hue for the rest of the image. So, the output results would actually look like this (edited in Paint.NET):
Allow me to use another sample image to test with that contains more image data:
As before with the first image sample, the results could be something like:
When the results I desire should be like so:
One idea I had was after the HUE change, replace the bottom left most color with the color from the original, but I am not sure if this is the correct approach or not, and even if it is I am not sure how to replace color X for another color. (Graphics and Math is beyond me).
For example, if I drew two blue color circles on Mickey's ear (the blue been the original transparent color from bottom left most pixel) and also colored his eyes:
Changing the HUE again may look like:
when in fact it should like this:
Simply put I would like to change the HUE of an image whether it be by the methods used from the EFG demo or another solution. The transparent color as defined by the bottom most left pixel should not be changed when the HUE is changed, this should remain the same as demonstrated in the sample images.
How can I change the HUE of a bitmap whilst retaining the background color?