[Mono-bugs] [Bug 80681][Nor] Changed - After a bitmap is locked for ReadWrite the image is damaged using the PixelFormat Format24bppRgb.
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Wed Jan 31 14:27:42 EST 2007
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by bernd.amend at googlemail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=80681
--- shadow/80681 2007-01-31 12:44:44.000000000 -0500
+++ shadow/80681.tmp.18083 2007-01-31 14:27:42.000000000 -0500
@@ -123,6 +123,42 @@
}
}
------- Additional Comments From sebastien at ximian.com 2007-01-31 12:44 -------
For your first sample the problem occurs when unlocking. Commenting
the UnlockBits produce a correct output bitmap.
+
+------- Additional Comments From bernd.amend at googlemail.com 2007-01-31 14:27 -------
+Are you sure? If I doesn't unlock the bitmap, the bitmap is saved at
+the previous state.
+
+using System.Drawing;
+using System.Drawing.Imaging;
+class MainClass
+{
+ public static void Main(string[] args)
+ {
+ Bitmap bitmap = new Bitmap("image.jpg");
+ BitmapData bmData = bitmap.LockBits(new
+Rectangle(0,0,bitmap.Width,bitmap.Height),
+ImageLockMode.ReadWrite,PixelFormat.Format24bppRgb);
+ bitmap.Save("image1.png",ImageFormat.Png); // image is ok
+ unsafe {
+ byte *imgPtr = (byte*)(bmData.Scan0);
+ for( int i = 0 ; i < bmData.Height ; i ++ ) {
+ for( int j = 0 ; j < bmData.Width ; j ++ ) {
+ imgPtr[0] = 0;
+ imgPtr[1] = 255;
+ imgPtr[2] = 255;
+
+ imgPtr += 3;
+ }
+ imgPtr += bmData.Stride - bmData.Width * 3;
+ }
+ }
+ bitmap.Save("image2.png",ImageFormat.Png);// image is ok, but it's
+the pre-locked image
+ bitmap.UnlockBits(bmData);
+ bitmap.Save("image3.png",ImageFormat.Png); // image is
+ok and yellow
+ }
+}
More information about the mono-bugs
mailing list