我该如何调整图像尺寸在C#中,同时保持高品质的? [英] How can I resize an image in C# while retaining high quality?

查看:218
本文介绍了我该如何调整图像尺寸在C#中,同时保持高品质的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现在图像处理的文章在这里:<一href="http://www.switchonthe$c$c.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing" rel="nofollow">http://www.switchonthe$c$c.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing一切工作正常。

I found an article on image processing from here: http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing Everything works fine.

我要调整图像大小时,保持高品质。我想,如果我可以增加DPI值,我可以做到这一点。有谁知道这是否可能?如果是的话,我怎么能在C#中实现它?

I want to keep the high quality when resizing the image. I think if I can increase the DPI value I can achieve this. Does anyone know if this is possible? And if so, how can I implement it in C#?

推荐答案

对于初学者来说,这是值得指出的是,有图像两大类;载体[例如SVG,WMF,Adobe Illustrator和Corel绘图图形]和位图(也叫光栅)图像[例如:位图,JPEG和PNG图像。

For starters, it's worth pointing out that there are two general categories of images; vector [e.g. SVG, WMF, Adobe Illustrator and Corel Draw Graphics] and bitmap (also called raster) images [e.g. Bitmap, JPEG and PNG Images].

矢量图像从一系列数学方程和/或计算的形成。位图图像,在另一方面,是由单独的点(像素)的每个对应于图像拍摄的物体上的特定特征的

Vector images are formed from a series of mathematical equations and/or calculations. Bitmap images, on the other hand, are made up of individual dots (pixels) each corresponding to a particular feature on the object the image is taken of.

如果它应该发生,你要调整图像大小,首先要考虑的是,如果它是一个位图或矢量图。凭借该矢量图像从计算获得的事实,它们可以完全地调整,而不会丢失任何细节。此案是位图图像不同。由于每个像素都独立于其它的,当你的愿望来调整其大小,则简单地增加或减少的源到目标像素比率

If it should happen that you want to resize an image, the first thing to consider is if it is a bitmap or vector image. By virtue of the fact that vector images are obtained from calculations, they can be perfectly resized without losing any detail. The case is different for bitmap images. Since each pixel is independent of the other, when you desire to resize it, you are simply increasing or decreasing the source to target pixel ratio.

因此​​,为了增加一倍矢量图像的大小,只需乘以2的目标维度和一切出来的所有权利。如果你要申请一个位图相同的效果,你实际上是增加每个源像素涵盖四个像素(两排两个水平像素)。

So in order to double the size of a vector image, simply multiply the target dimensions by two and everything comes out all right. If you should apply the same effect on a bitmap, you are actually increasing each source pixel to cover four pixels (two rows of two horizontal pixels).

当然,通过采用插值和滤波,计算机可以顺利出了目标像素的边缘,因此,他们似乎融入对方,并给予合理的调整后的图像的外观,但这个输出是永远不会一样调整矢量图像;矢量图像缩放完美。

Of course, by applying interpolation and filtering, the computer can "smooth" out the edges of the target pixels so they seem to blend into each other and give the appearance of a reasonably resized image but this output is never the same as resizing a vector image; vector images resize perfectly.

您可以在你的问题中提到的 DPI 。 DPI是基本上对应于一英寸时图像的印刷的而不是当它是观看的屏幕上的像素的数目的。因此,通过增加图像的DPI,不增加图像的尺寸在屏幕上。你只增加了打印的质量[这不用说取决于打印机的最高分辨率。

You also mentioned DPI in your question. DPI is essentially the number of pixels that correspond to an inch when the image is printed not when it is viewed on a screen. Therefore by increasing the DPI of the image, you do not increase the size of the image on the screen. You only increase the quality of print [which needless to say depends on the maximum resolution of the printer].

如果你真的希望调整图像大小,图像是位图,作为一个经验法则,不增加超出原始图像的大小否则你将失去质量的200%大小。

If you really desire to resize the image and the image is a bitmap, as a rule of thumb, do not increase the size beyond 200% of the original image's size else you'll lose the quality.

您可以看到的这个答案为code来调整位图图像。

You can see this answer for code to resize bitmap images.

要看到一个样本矢量图像,去的这个链接
注意试放大和缩小图像,以了解其调整大小。

To see a sample vector image, go to this link.
Note Try zooming in and out of the image to see how well it resizes.

一个典型的位图是计算器精灵。他们不保持自己的质量大小。


进一步阅读

A typical bitmap are the StackOverflow sprites. They do not keep their quality resized.


Further Reading

  • Vector Graphics: http://en.wikipedia.org/wiki/Vector_image
  • Bitmap Graphics: http://en.wikipedia.org/wiki/Bitmap_image

这篇关于我该如何调整图像尺寸在C#中,同时保持高品质的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆