[Mono-dev] Bug in System.Drawing or libgdiplus

Sebastien Pouliot sebastien.pouliot at gmail.com
Tue Jan 30 15:10:39 EST 2007


Hello Bernd,

Please fill a bug report into http://bugzilla.ximian.com
and I'll look at this ASAP

Thanks

On Sat, 2007-01-27 at 22:27 +0100, Bernd Amend wrote:
> Hi, 
> 
> I have a problem with Mono programs that use System.Drawing, on Gentoo
> (x86, x86_64) or with the Linux Installer with mono 1.2.2.1 and
> libgdiplus 1.2.2 or 1.2.1.
> On Windows with .Net 2.0 and Mono 1.2.2.1 and Ubuntu 6.10 with Mono
> 1.1.13.6 and and Gentoo with Mono 1.13.8.1 and libgdiplus 1.1.13.2 the
> created images testimage-invalid.png and testimage-valid.png are correct
> and yellow.
> With Mono 1.2.2.1 the image testimage-valid.png is yellow, after the
> bitmap is locked again for readwrite the bitmap is crap see
> testimage-invalid.png. 
> 
> You have to compile it with "mcs /unsafe /r:System.Drawing main.cs" and
> start the application with mono main.exe. 
> It creates the images testimage-valid.png and testimage-invalid.png.
> 
> If I create an image with PixelFormat.Format32bpp Rgb or Argb the
> problem doesn't occurs. I think this is a Bug in libgdiplus or cairo but
> i am not sure.
> 
> 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 
>       bitmap.UnlockBits(bmData); 
> 
>       bitmap.Save("testfile-invalid.png",ImageFormat.Png); // image is
> incorrect 
>    } 
> }
> 
> The same problem occurs here:
> (mcs /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("image.jpg");
> 		BitmapData bmData = bitmap.LockBits(new
> Rectangle(0,0,bitmap.Width,bitmap.Height),
> ImageLockMode.ReadWrite,PixelFormat.Format24bppRgb);
> 		bitmap.UnlockBits(bmData);
> 		bitmap.Save("image.png",ImageFormat.Png);
> 	}
> }
> 
> Regards
> Bernd Amend
> 
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
-- 
Sebastien Pouliot  <sebastien at ximian.com>
Blog: http://pages.infinit.net/ctech/




More information about the Mono-devel-list mailing list