I'm no grahics wiz, I'm sure there's a cool way to do this with GDI+, but at least you can start by getting rid of the floats, and move out the temp-allocations. I.e.:
Color c;
int luma;
for (int x = 0; x < m_Bitmap.Width; x++)
{
c = m_Bitmap.GetPixel(x, y);
luma = (c.R * 30 + c.G * 59 + c.B * 11)/100;
m_Bitmap.SetPixel(x, y, Color.FromArgb(luma, luma, luma));
}
You might also gain a bit by pre-generating the Color-structures (since you're doing Color.FromArg(luma, luma, luma) there are only 256 possible values). Create an array with 256 entires, and place ready-mady Color-structures there. Something like this:
// Do this first - outside both loops
Color[] colors = new Color[256];
for (int i = 0; i < colors.Length; i++)
{
colors[i] = Color.FromArgb(i, i, i);
}
// then you can do...
m_Bitmap.SetPixel(x, y, colors[luma]);
Svante
AxCrypt - Free Open Source File Encryption & Online Password Manager -
http://www.axantum.com[Disclaimer: Code snippets usually uncompiled, beware typos.]
______
Don't forget to click "Mark as Answer" on the post(s) that helped you.