M
moss
Hi people,
I have a weird problem with creating a negative image. I'm working on
this image viewer application in VS 2008 on Windows 7 64-bit and when
I try to create a negative from the original image, my negative image
ends up being totally black, every pixel is RGB(0,0,0). This is the
code I'm using for this purpose:
ImageAttributes ia = new ImageAttributes();
ColorMatrix cm = new ColorMatrix();
cm.Matrix00 =
cm.Matrix11 =
cm.Matrix22 = -1;
ia.SetColorMatrix(cm);
Graphics g = Graphics.FromImage(MyBitmap);
g.DrawImage(MyBitmap, new Rectangle(0, 0, MyBitmap.Width,
MyBitmap.Height), 0, 0, MyBitmap.Width, MyBitmap.Height,
GraphicsUnit.Pixel, ia);
g.Dispose();
When I run the program on Windows XP 32-bit and Vista 32-bit there is
no problem at all, the negative image looks fine, and I'm able to
invert it back to the original one. Then I read this article:
http://www.bobpowell.net/negativeimage.htm
I used Bob Powell's solution to shift the colors a little bit before
inverting the image, but I get the same blackened result on my 64-bit
machine. So I'm guessing this is some sort of 64-bit issue, because
the numbers are probably represented in a different way and there is
some zero multiplication going on between matrices to produce this
result. (I'm a novice programmer, don't know much about the 64-bit
architecture). Any ideas on how to fix this without having to use the
slow SetPixel method?
I have a weird problem with creating a negative image. I'm working on
this image viewer application in VS 2008 on Windows 7 64-bit and when
I try to create a negative from the original image, my negative image
ends up being totally black, every pixel is RGB(0,0,0). This is the
code I'm using for this purpose:
ImageAttributes ia = new ImageAttributes();
ColorMatrix cm = new ColorMatrix();
cm.Matrix00 =
cm.Matrix11 =
cm.Matrix22 = -1;
ia.SetColorMatrix(cm);
Graphics g = Graphics.FromImage(MyBitmap);
g.DrawImage(MyBitmap, new Rectangle(0, 0, MyBitmap.Width,
MyBitmap.Height), 0, 0, MyBitmap.Width, MyBitmap.Height,
GraphicsUnit.Pixel, ia);
g.Dispose();
When I run the program on Windows XP 32-bit and Vista 32-bit there is
no problem at all, the negative image looks fine, and I'm able to
invert it back to the original one. Then I read this article:
http://www.bobpowell.net/negativeimage.htm
I used Bob Powell's solution to shift the colors a little bit before
inverting the image, but I get the same blackened result on my 64-bit
machine. So I'm guessing this is some sort of 64-bit issue, because
the numbers are probably represented in a different way and there is
some zero multiplication going on between matrices to produce this
result. (I'm a novice programmer, don't know much about the 64-bit
architecture). Any ideas on how to fix this without having to use the
slow SetPixel method?