Posted By: Angus | Aug 2nd, 2005 @ 8:54 AM
page 1 of 1
Comments: 9 | Views: 12054 | Downloads: 125
Angus
Angus
.
Download:Link for Invert Colors(0 Bytes)
This program is one that inverts the colors of a picture. I was hoping that someone could tell me a way of making this program work faster, as currently it is somewhat lacking in speed.

Thanks in advance

Angus Higgins
Instead of

                        int R = UserImage.GetPixel(WidthPixels, HeightPixels).R;
                        int G = UserImage.GetPixel(WidthPixels, HeightPixels).G;
                        int B = UserImage.GetPixel(WidthPixels, HeightPixels).B;
                        UserImage.SetPixel(WidthPixels, HeightPixels, Color.FromArgb(255 - R, 255 - G, 255 - B));

couldn't you do
                        int invert = 0xFFFFFF;
                        UserImage.SetPixel(WidthPixels, HeightPixels, Color.FromArgb(UserImage.GetPixel(WidthPixels, HeightPixels).ToArgb ^ invert);

(or some other more efficient way of XORing every pixel in the picture)?
Use a ColorMatrix. It will be almost instant.
Maurits
Maurits
AKA Matthew van Eerde
John Galt wrote:
Use a ColorMatrix. It will be almost instant.


ColorMatrix example from Bob Powell
Image img=Image.FromFile(<filename>);
Bitmap copy=new Bitmap(img.Width,img.Height);
ImageAttributes ia = new ImageAttributes();
ColorMatrix cm=new ColorMatrix();
cm.Matrix00=-1;
cm.Matrix11=-1;
cm.Matrix22=-1;
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();
Pretty interesting program I must say.
Loadsgood
Loadsgood
What is your answer?
Can anyone convert his app into a .NET 1.1 app? I'm too lazy to install .NET 2.0 and I'd love to be able to use it.



Make the Change Brightness program have its own thread.
Loadsgood.
page 1 of 1
Comments: 9 | Views: 12054 | Downloads: 125
Microsoft Communities