I read in this that you want to do pixel manipulation with a bitmap. So, logically, you want to access the pixels as an array to do this.
The problem is that your appearance is fundamentally wrong, and the other guys didn't pick it up - and maybe this is what they can take away?
Basically, you still get to the pointers from the bitmap images, I'm going to give you one of my earned “secrets”.
YOU NEED TO COPY A BITMAP TO AN ARRAY. Just use it as is.
Unsafe pointers are your friend in this case. When you hit "bitmapData.Scan0.ToPointer ()", you missed the trick.
As long as you have a pointer to the first pixel and Stride, and you know the number of bytes per pixel, you get into the winner.
I specifically define a bitmap with 32 bits per pixel (memory is efficient for UInt32 access), and I get a pointer to the first pixel. Then I treat the pointer as an array and can both read and write pixel data as UInt32 values.
Code speaks louder than words. Take a look.
I salute you for making this so far!
This is unverified code, but a lot is copied from my source.
public delegate void BitmapWork(UInt32* ptr, int stride);
Simon miller
source share