I'm using C# and the latest release of Visual Studio 2005.
I have written a small filter to modify an image that is being loaded by some picture boxes. The filter works great except it takes about 30 to 40 seconds to run. How can I speed this up
public void GreyFilter()
{
Color pixel; int t; for (int y = 0; y < mainImage.Height; y++){
for (int x = 0; x < mainImage.Width; x++){
pixel = mainImage.GetPixel(x, y);
t = (pixel.R + pixel.G + pixel.B) / 3;
mainImage.SetPixel(x, y,
Color.FromArgb(t, t, t));}
}
MessageBox.Show("done");}

GetPixel/SetPixel very very slow...
shauli
I found an example for anyone that wants to do this:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/dncscol/html/csharp11152001.asp
vindos
darrellp
Thank you. Do you have an example
Keehan
See Bob Powells site for more info:
http://www.bobpowell.net/grayscale.htm
Shinji
You may also want to consider using a ColorMatrix to modify the image as you draw it.
See Bob Powells site for more info:
http://www.bobpowell.net/grayscale.htm
Thank you. I'll give this a try.