[Mono-bugs] [Bug 81998][Min] New - Lockbits results in extra bytes for non 32-bit bitmaps

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Jul 3 10:28:16 EDT 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 smclellan at mintel.com.

http://bugzilla.ximian.com/show_bug.cgi?id=81998

--- shadow/81998	2007-07-03 10:28:16.000000000 -0400
+++ shadow/81998.tmp.13368	2007-07-03 10:28:16.000000000 -0400
@@ -0,0 +1,114 @@
+Bug#: 81998
+Product: Mono: Class Libraries
+Version: 1.2
+OS: other
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: libgdiplus
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: smclellan at mintel.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Lockbits results in extra bytes for non 32-bit bitmaps
+
+Description of Problem:
+On: FreeBSD 6.1-STABLE  -  libgdiplus 1.2.3 (from tarball), mono 1.2.3.1
+(ports)
+
+With the code below (in additional information), where the bitmap is any
+bitmap saved in non 32-bit format, extra bytes are observed when iterating
+over the bytes in BitmapData. When run under Windows (through Visual
+Studio) the expected result is seen. This looks to be a problem in the way
+libgdiplus is internally representing the image. It does not seem to matter
+what PixelFormat is passed to LockBits.
+
+For bitmaps saved in 32-bit format the expected result is seen in both
+Windows and Mono.
+
+
+Steps to reproduce the problem:
+1. Compile the code below with gmcs -unsafe -r:System.Drawing.dll
+2. Put a 10 X 2 24-bit bitmap in the directory called a.bmp
+3. Run the code
+
+Where the image is a 10 X 2 pixel 24-bit bitmap.
+
+Actual Results:
+128 128 128 255
+255 128 128 255
+128 255 128 255
+128 128 255 255
+128 128 128 255
+255 128 128 255
+128 255 128 255
+128 128 255 255
+128 128 128 255
+255 128 128 255
+... repeated for second row
+
+Expected Results:
+128 128 128 255
+128 128 128 255
+128 128 128 255
+128 128 128 255
+128 128 128 255
+128 128 128 255
+128 128 128 255
+128 128 128 255
+128 128 128 255
+128 128 128 255
+... repeated for second row
+
+
+How often does this happen? 
+
+All the time.
+
+Additional Information:
+
+// Code:
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Drawing;
+using System.Drawing.Imaging;
+
+namespace app
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+            Bitmap bm = new Bitmap("a.bmp");
+
+            BitmapData d = bm.LockBits(new Rectangle(0, 0, bm.Width,
+bm.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb);
+            unsafe
+            {
+                for (int y = 0; y < d.Height; ++y)
+                {
+                    byte* ptr = (byte*)d.Scan0 + y * d.Stride;
+
+                    for (int x = 0; x < d.Width; ++x)
+                    {
+                        Console.Write("{0} ", *ptr++);
+                        Console.Write("{0} ", *ptr++);
+                        Console.Write("{0} ", *ptr++);
+                        Console.Write("{0} ", *ptr++);
+                        Console.WriteLine();
+                    }
+
+                    Console.WriteLine();
+                }
+            }
+            bm.UnlockBits(d);
+            Console.WriteLine(bm.Width);
+        }
+    }
+}


More information about the mono-bugs mailing list