This project is read-only.

BitmapData And Marshal.Copy

Oct 8, 2011 at 7:00 PM

I have been looking around and trying to figure out what alternative there is for windows phone 7.1 for BitmapData. I have Commented out the code in question.

I am aware of Lockbits and that its fast in comparison to get set pixels and so on. As per my understanding, BitmapData Locks the image to memory ready for manipulation.

BmpData.Scan0 acts as a pointer to the memory.

If I were to do this without BitmapData, and manipulate some of image data.

How could use WriteableBitmapEx to mimic this operation? Any help appreciated. Thanks

int Edit(Bitmap BmpIn, byte[] BIn, byte BitsPerByte) { int LengthBytes = 1 + 31 / BitsPerByte; int TextLength = 1 + (8 * BIn.Length - 1) / BitsPerByte; //BitmapData BmpData = BmpIn.LockBits(new Rectangle(0, 0, BmpIn.Width, BmpIn.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); RGB = new byte[2 + LengthBytes + TextLength]; //Marshal.Copy(BmpData.Scan0, RGB, 0, RGB.Length); InsertBitsPerByte(BitsPerByte); SetMasks(BitsPerByte); InsertLength(LengthBytes, TextLength, BitsPerByte); InsertBytes(BIn, BitsPerByte); //Marshal.Copy(RGB, 0, BmpData.Scan0, RGB.Length); BmpIn.UnlockBits(BmpData); return TextLength; }