问题描述
因此,我创建了一个函数,可以通过在用户指定尺寸的网格中查找和设置平均颜色来从图像中创建像素艺术。但是,尽管新图片看起来像像素图,但每个“像素”都是相同颜色的实际像素的网格。我下面的调整大小功能将图像的高度和宽度除以网格中较小像素的数量。而且我很奇怪为什么更改插值模式后所有结果变得模糊。任何帮助是极大的赞赏。 原版的: face
如果我将模糊的图片上传到类似Piskel.com的程序中,则可以看到像素大小是准确的,因此我认为问题不在于比例。 编辑:调整大小后的图片应该看起来与像素艺术完全一样
public static Bitmap Resize(Bitmap bmp,int scaleFactor)
{
//Where bmp is mypic.Image as a bitmap,scaleFactor is what I want to scale down by
int newWidth = bmp.Width / scaleFactor;
int newHeight = bmp.Height / scaleFactor;
Bitmap newImage = new Bitmap(newWidth,newHeight);
using (var graphics = Graphics.FromImage(newImage))
{
graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
graphics.PixelOffsetMode = PixelOffsetMode.Half;
graphics.DrawImage(bmp,newWidth,newHeight);
}
return newImage;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)