Bitmap.LockBits Does Not Behave as Expected
-
Friday, August 18, 2006 4:51 PM
I am using Compact Framework 2.0 / Windows Mobile 5.0 Emulator
When I try to use Lockbits with a Rectangle smaller than the full size of the Bitmap
Lockbits thows a System.ArgumentException "Value does not fall within the expected range."
Lockbits does not do this in a windows desktop application
//This Works
Bitmap bmp = new Bitmap(128,128, PixelFormat.Format24bppRgb);
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
PixelFormat pf = PixelFormat.Format24bppRgb;
BitmapData bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite,pf);//If I Try to use a Rectangle not the Full Size of the Bitmap
//I Get a System.ArgumentException "Value does not fall within the expected range."
Bitmap bmp = new Bitmap(128,128, PixelFormat.Format24bppRgb);
Rectangle rect = new Rectangle(0, 0, bmp.Width/2, bmp.Height/2);
PixelFormat pf = PixelFormat.Format24bppRgb;
BitmapData bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite,pf);
Answers
-
Friday, August 18, 2006 5:06 PMModerator
That is by design limitation on devices.
All Replies
-
Friday, August 18, 2006 5:06 PMModerator
That is by design limitation on devices.
-
Monday, August 21, 2006 4:39 PM
Thanks Ilya
I will find another way
It does not indicate that in the reference

