How To Transform Color?
- From: "Nobody" <nobody@xxxxxxx>
- Date: Wed, 26 Oct 2005 01:53:40 -0700
I have a bitmap file that I use as part of a skin in my GUI. Never mind that
its a GUI or Windows based, that part isn't important.
The problem is that say the graphic is blue, but the user selects a green
color scheme. I want the graphic skin to be green-ish instead of blue-ish.
My idea was to shift the R,G,B values of each pixel in the bitmap towards
the R,G,B values of the foreground color. I figured this would maintain the
shape and "lighting" of the bitmap. A sort of blending the original color
with the new foreground color. I came up with this:
rgbq.rgbRed += (10 + ((GetRValue(cr) - rgbq.rgbRed) * 5 / 8));
rgbq.rgbGreen += (10 + ((GetGValue(cr) - rgbq.rgbGreen) * 5 / 8));
rgbq.rgbBlue += (10 + ((GetBValue(cr) - rgbq.rgbBlue) * 5 / 8));
1) I get the new foreground color in cr
2) rgbq is a struct that represents a pixel (this code is in a for loop
going through each pixel in the bitmap)
3) I take take the difference of the red values * 5/8 and add it to the
original red value
4) I add 10 to "lighten" the color a bit...
This seems to work OK, the original "grayish" bitmap is now "purpleish" or
whatever... but the problem is the original bitmap was a sort of spherish
shape (use of lighting from the upper left going to the lower right), but
the resulting bitmap, although in the right color realm, seems to have
"flattened" the image... ie.. it lost the lighting effect.
I've checked to make sure the value never goes above 255. And I am POSITIVE
that the getpixel and setpixel portion of the code is correct since I am
successfully using the same function to apply other effects to the bitmap.
Just this transforming thing seems to be flattening it.
Any ideas?
.
- Follow-Ups:
- Re: How To Transform Color?
- From: Nils
- Re: How To Transform Color?
- Prev by Date: Re: What does "UV" stand for in UV Mapping
- Next by Date: Re: polygon intersection
- Previous by thread: CGM Viewer
- Next by thread: Re: How To Transform Color?
- Index(es):
Relevant Pages
|