Fastest possible update of a Bitmap

Hi

Assuming image is a Bitmap, is this the quickest way (outside of hardware) to manipulate the bytes?

bmData = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppRgb);

scanline = bmData.Stride;
Scan0 = bmData.Scan0;

q = (int *)(void *)Scan0;

*(q + offest) = someByte

image.UnlockBits(bmData);

Thanks

[493 byte] By [AlanSimes] at [2007-12-16]
# 1
Sortof. There's quite a lot of overhead associated with LockBits(), so you should use it sparingly. It's best used when you want to update many pixels at once.

-Ryan / Kardax

RyanLamansky at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 2
No, there is a way that is often faster, and does not require unsafe code. I have wrapped it in a class. See this EffectBuffer class.
FrankHileman at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...
# 3
Ah, yes... that is a good way. I do something similar (but not quite that good--I'll have to update my approach :)

You're correct that it doesn't require the use of "unsafe" code, but it does require Full Trust, which is almost the same thing...

-Ryan / Kardax

RyanLamansky at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# General...