[Mono-bugs] [Bug 80681][Maj] New - 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
Tue Jan 30 19:06:49 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-30 19:06:49.000000000 -0500
+++ shadow/80681.tmp.21842	2007-01-30 19:06:49.000000000 -0500
@@ -0,0 +1,124 @@
+Bug#: 80681
+Product: Mono: Class Libraries
+Version: 1.2
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: libgdiplus
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: bernd.amend at googlemail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: After a bitmap is locked for ReadWrite the image is damaged using the PixelFormat Format24bppRgb.
+
+Description of Problem:
+After a bitmap is locked for ReadWrite the image is damaged using the
+PixelFormat Format24bppRgb.
+(bitmap.LockBits(new Rectangle(0,0,bitmap.Width,bitmap.Height),
+ImageLockMode.ReadWrite,PixelFormat.Format24bppRgb);)
+
+The problem occurs on Gentoo (x86, x86_64) and with the Linux Installer
+with mono 1.2.2.1 and with the preview of mono 1.2.3 and the corresponding
+libgdiplus Version.
+On Windows with .Net 2.0 and Mono 1.2.2.1 and Mono 1.1.13.6 and Gentoo with
+Mono 1.13.8.1 and libgdiplus 1.1.13.2 the problem doesn't occurs.
+
+Actual Results:
+The image is damaged after it is locked for ReadWrite.
+
+Expected Results:
+The image should be identical to the image before it is locked.
+
+How often does this happen? 
+ever
+
+Additional Information: Below are two examples.
+In this example the saved image "image.png" is damaged.
+The problem occurs here: (mcs /r:System.Drawing main.cs)
+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); // it seams the
+problem occurs here
+                bitmap.UnlockBits(bmData);
+                bitmap.Save("image.png",ImageFormat.Png);
+        }
+}
+
+
+In this example two images are created testimage-valid.png and
+testimage-invalid.png.
+Both should be yellow, if the second image is not yellow the program prints
+"Test failed".
+main.cs : (mcs /unsafe /r:System.Drawing main.cs)
+using System;
+using System.Drawing; 
+using System.Drawing.Imaging; 
+
+class MainClass 
+{ 
+   public static void Main(string[] args) 
+   { 
+      Bitmap bitmap = new Bitmap(100,100); 
+      BitmapData bmData = bitmap.LockBits(new
+Rectangle(0,0,bitmap.Width,bitmap.Height),
+ImageLockMode.ReadWrite,PixelFormat.Format24bppRgb); 
+      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.UnlockBits(bmData); 
+       
+      bitmap.Save("testfile-valid.png",ImageFormat.Png); // imaged is saved
+perfect 
+
+      bmData = bitmap.LockBits(new
+Rectangle(0,0,bitmap.Width,bitmap.Height),
+ImageLockMode.ReadWrite,PixelFormat.Format24bppRgb); // it seams the
+problem occurs here
+      unsafe {
+      // check if bitmap is correct
+         byte *imgPtr = (byte*)(bmData.Scan0); 
+         for( int i = 0 ; i < bmData.Height ; i ++ ) { 
+                    for( int j = 0 ;  j < bmData.Width ;  j ++ ) { 
+                        if (!(imgPtr[0] == 0 && imgPtr[1] == 255 &&
+imgPtr[2] == 255)) {
+                        // :( failed
+                        	Console.WriteLine("Test failed");
+                        	i=bmData.Height;
+                        	break;
+                        }
+                        
+                        imgPtr += 3; 
+                    } 
+                    imgPtr += bmData.Stride - bmData.Width * 3; 
+                } 
+      } 
+      bitmap.UnlockBits(bmData); 
+
+      bitmap.Save("testfile-invalid.png",ImageFormat.Png); // image is
+incorrect 
+   } 
+}


More information about the mono-bugs mailing list