C#图像处理像素位置 [英] C# image processing pixel location
本文介绍了C#图像处理像素位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想加载图片,然后想要调整大小,然后保存新调整大小的图像。
如下所示
i want to load an image and then want to resize it and then save the new resized image.
like the following
g.DrawImage(img, new Rectangle(0, 0,
(int)(rect.Width - 200 * dCurZoom), (int)(rect.Height - 200 * dCurZoom))) ;
但问题是调整大小的图像是在原始图像上绘制的,我无法保存新调整大小的图像seperatel。请帮帮我!!!
but problem is this that the resized image is drawn on original one and i am not able to save the new resized image seperatel. please help me!!!
推荐答案
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;
}
这篇关于C#图像处理像素位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文