[Mono-bugs] [Bug 76844][Nor] New - Unlockbits fails

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Nov 28 21:15:10 EST 2005


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 miguel at ximian.com.

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

--- shadow/76844	2005-11-28 21:15:10.000000000 -0500
+++ shadow/76844.tmp.23888	2005-11-28 21:15:10.000000000 -0500
@@ -0,0 +1,63 @@
+Bug#: 76844
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Windows.Forms
+AssignedTo: peter at novonyx.com                            
+ReportedBy: miguel at ximian.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Unlockbits fails
+
+The following program should render a magenta image in file "s.jpg"
+instead it renders a silver image (we clear the image at startup to be silver).
+
+I suspect the unlocking does not copy the data *back* into the bitmap.
+
+To compile and run:
+   mcs -pkg:dotnet file.cs
+   mono file.exe
+   eof s.jpg     ## (to view)
+
+
+using System;
+using System.Drawing;
+using System.Drawing.Imaging;
+
+class X {
+        static void Main ()
+        {
+                Bitmap b = new Bitmap(100, 100, PixelFormat.Format32bppArgb);
+                BitmapData bmData = b.LockBits (new Rectangle(0, 0,
+b.Width, b.Height),
+                                                ImageLockMode.ReadWrite,
+PixelFormat.Format24bppRgb);
+                Graphics     g = Graphics.FromImage(b);
+                g.Clear(Color.Silver);
+
+
+                unsafe {
+                        System.IntPtr Scan0 = bmData.Scan0;
+                        byte * p = (byte *)(void *)Scan0;
+                        int nWidth = b.Width;
+                        int nHeight = b.Height;
+
+                        for(int y=0;y < nHeight;++y) {
+                                for(int x=0; x < nWidth; ++x ) {
+                                        *p++ = 255;
+                                        *p++ = 0;
+                                        *p++ = 255;
+                                }
+                        }
+                }
+                b.UnlockBits(bmData);
+                b.Save ("s.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
+        }
+}


More information about the mono-bugs mailing list