且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C#图像处理像素位置

更新时间:2023-01-24 14:32:48

if (img.Width != width || img.Height != height)
                {
                    Bitmap newImage = new Bitmap(width, height);
                    using (Graphics gr = Graphics.FromImage(newImage))
                    {
                        gr.SmoothingMode = SmoothingMode.HighQuality;
                        gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
                        gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
                        gr.DrawImage(img, new Rectangle(0, 0, width, height));
                    }

                    img.Dispose();
                    img = newImage;
                }