monroe
11/17/2004 12:25:00 PM
Hi all,
Ok, this is possibly a newbie question, but I'm kind of a newbie
anyway, so here it goes :)
I have a Bitmap I need to control through a ControlMatrix. I can
easily make changes to the brightness or contrast of the picture. If I
got it right, being X the elements I need to change, it goes...
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
X X X 0 1
for brightness, and
X 0 0 0 0
0 X 0 0 0
0 0 X 0 0
0 0 0 1 0
0 0 0 0 1
for Contrast. The problem comes with the Saturation...elements that
change are
X X X 0 0
X X X 0 0
X X X 0 0
0 0 0 1 0
0 0 0 0 1
I can also change the Saturation with no problems at all.
Trouble comes if I try to change the Contrast _and_ Saturation of the
bitmap...I'm guessing it's because of the elements (0,0) (1,1) and
(2,2) affecting both Contrast and Saturation when I make a change for
one of them, but the fact is I'm getting some weird side effects :D
The bitmap changes but definitely not how it's supposed to.
This is because I'm using just one Matrix, where I update all desired
changes and then apply it to the original bitmap to get the result I
show to the user.
For example, I could DrawImage with a ColorMatrix that looks like
this...
3 0 0 0 0
0 3 0 0 0
0 0 3 0 0
0 0 0 1 0
2 2 2 0 1
to change both Contrast and Brightness at the very same time.
I do it this way after trying a different view; saving the result
bitmap after a transformation, generating a new identity matrix,
setting the new desired transformation into it and then applying it to
the bitmap to get a new result. This system obviously had undesireable
results; if I, for example, set the contrast to 0 and then to 1 again
I've lost the original bitmap into a black one.
So the question is (and probably the answer is easy, I'm way too bad
in algebra for this, I'm missing something or I'm simply a noob)...How
can I set the contrast of a bitmap to A and it's color Saturation to B
using only one ColorMatrix and one DrawImage method?
Thanks all