G
Guest
I have an C# PPC app and am experiencing extream lag time when manipulating
pixel values in an Image object. Is there a way to make the GetPixel /
SetPixel operation faster ?
my image is 144x256 pixel and takes about 3 minutes to simply invert the
colors using the following code:
**********************************************************
if (chkInvert.Checked)
{
Color tmpclr, newClr;
int r, g, b;
Bitmap img2Invert = new Bitmap(pictureBox1.Image);
//loop through the image and invert each pixel
for (int iy = 0; iy < img2Invert.Height; iy++)
for (int ix = 0; ix < img2Invert.Width; ix++)
{
tmpclr = img2Invert.GetPixel(ix, iy);
r = 255 - tmpclr.R;
g = 255 - tmpclr.G;
b = 255 - tmpclr.B;
newClr = Color.FromArgb(r, g, b);
img2Invert.SetPixel(ix, iy, newClr);
}
pictureBox1.Image = img2Invert;
}
************************************************************
Help with this would be much appreciated.
pixel values in an Image object. Is there a way to make the GetPixel /
SetPixel operation faster ?
my image is 144x256 pixel and takes about 3 minutes to simply invert the
colors using the following code:
**********************************************************
if (chkInvert.Checked)
{
Color tmpclr, newClr;
int r, g, b;
Bitmap img2Invert = new Bitmap(pictureBox1.Image);
//loop through the image and invert each pixel
for (int iy = 0; iy < img2Invert.Height; iy++)
for (int ix = 0; ix < img2Invert.Width; ix++)
{
tmpclr = img2Invert.GetPixel(ix, iy);
r = 255 - tmpclr.R;
g = 255 - tmpclr.G;
b = 255 - tmpclr.B;
newClr = Color.FromArgb(r, g, b);
img2Invert.SetPixel(ix, iy, newClr);
}
pictureBox1.Image = img2Invert;
}
************************************************************
Help with this would be much appreciated.