颜色显示为蓝色的C#图片列表问题

时间:2020-05-07 07:41:32

标签: c#

我已经提出了一种打开特定格式的应用程序,当我打开它时,我得到了该文件中的所有图像,这是可行的,但问题是应用程序将图片更改为蓝色

我正在使用它:

 private Image CreateThumbnail(Image original, int w, int h)
        {
            Bitmap canvas = new Bitmap(w, h);

            Graphics g = Graphics.FromImage(canvas);
            g.FillRectangle(new SolidBrush(Color.White), 0, 0, w, h);

            float fw = (float)w / (float)original.Width;
            float fh = (float)h / (float)original.Height;

            float scale = Math.Min(fw, fh);
            fw = original.Width * scale;
            fh = original.Height * scale;

            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;

            g.DrawImage(original,
                new RectangleF((w - fw) / 2, (h - fh) / 2, fw, fh),
                new RectangleF(0, 0, original.Width, original.Height), GraphicsUnit.Pixel);
            g.Dispose();

            return canvas;
        }

这是我的问题的照片:https://imgur.com/VyOYlDp 如果图像为黑色,它将变为蓝色

感谢您的帮助

0 个答案:

没有答案