Hi Im trying to create an negative image.
This is the code I use to do it. I got it from the Bob Powell FAQ.
The problem I have is, when Im click the button I get an out of memory exception at the g.DrawImage line.
Thanks for the help
This is the code I use to do it. I got it from the Bob Powell FAQ.
C#:
private void button2_Click(object sender, EventArgs e)
{
if(this.pictureBox1.Visible == true)
{
Image img = this.pictureBox1.Image;
Bitmap copy = new Bitmap(img.Width,img.Height);
ImageAttributes ia = new ImageAttributes();
ColorMatrix cm = new ColorMatrix();
cm.Matrix00 = cm.Matrix11 = cm.Matrix22 = 0.99f;
cm.Matrix33 = cm.Matrix44 = 1;
cm.Matrix40 = cm.Matrix41 = cm.Matrix42 = .04f;
ia.SetColorMatrix(cm);
Graphics g = Graphics.FromImage(copy);
g.DrawImage(img, new Rectangle(0, 0, img.Width, img.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, ia);
g.Dispose();
img.Dispose();
}
Thanks for the help
Last edited by a moderator: