mono / libgdiplus

C-based implementation of the GDI+ API
http://www.mono-project.com/
MIT License
329 stars 171 forks source link

Version 6.0.4 produces incorrect images on Linux #672

Closed iihmsunn closed 3 years ago

iihmsunn commented 3 years ago

I have this code for image resize in a .Net Core 3 app.

public static Image ResizeImage(Image img, SizeF targetSize)
        {
            float k;
            float ih = img.Height;
            float iw = img.Width;
            if ( (k = ih / iw) > targetSize.Height / targetSize.Width )
                targetSize.Width = targetSize.Height / k;
            else
                targetSize.Height = k * targetSize.Width;
            Bitmap targetImage = new Bitmap((int)targetSize.Width, (int)targetSize.Height);
            Graphics G = Graphics.FromImage(targetImage);
            G.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            G.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            G.DrawImage(img, new RectangleF(new PointF(0, 0), targetSize));
            return targetImage;
  }

When used with libgdiplus 6.0.4 shipped with Ubuntu 20.04 it produces an image that has a correct size but it's just filled with blank color.

When used with version 5.6.1 it works as expected.

filipnavara commented 3 years ago

This was likely already fixed by https://github.com/mono/libgdiplus/commit/c98de971e5f453f50f898494b7791feb02302f62#diff-aece1adffdec03902777be2a4a48ade5. Unfortunately there's probably no newer official build.

iihmsunn commented 3 years ago

Apparently yes, it was fixed since 6.1 from git is working thx