如何使用单个图像动态调整图像大小而不降低使用ASP.NET的图像质量 [英] How to dynamically resize the Image using single Image without decreasing the quality of image using ASP.NET

查看:80
本文介绍了如何使用单个图像动态调整图像大小而不降低使用ASP.NET的图像质量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用单个图像动态调整图像大小而不降低使用ASP.NET的图像质量



例如:我想允许用户下载图像成不同的分辨率。但我有单一的形象。并希望根据下拉列表中选择的尺寸调整图像大小。



请尽快提供解决方案....

提前谢谢你...!

解决方案

如果原始图像很好,这就叫做重新采样并且总是会降低质量质量。但是,如果缩小图像,质量问题可能非常小,但相比之下,如果将其放大,结果非常难看,通常是不可接受的。如果生成的图像太小也一样。



使用分形压缩可以获得一些放大效果,但这项技术是通常无法访问: http://en.wikipedia.org/wiki/Fractal_compression [ ^ ]。



调整图片大小.NET很简单。您只需打开原始位图,创建新位图并在新位图上绘制原始位图,使用适当的 System.Drawing.Graphics.DrawImage 方法将其缩放到目标大小:

http://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawimage.aspx[^]。



使用此构造函数从目标位图获取用于绘制的类 System.Drawing.Graphics 的实例:http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage.aspx [ ^ ] 。



就是这样。



-SA

How to dynamically resize the Image using single Image without decreasing the quality of image using ASP.NET

For eg: I want to allow the user to download the Image into different resolution. but i have single image. and want to resize the image according to the selected size in dropdown list.

Please provide the solution as soon as possible....
Thank you in advance...!

解决方案

This is called resampling and always reduce the quality, if the original image is of good quality. However, if you scale the image down, the quality problem can be very minor, but, in contrast, if you scale it up, results are quite ugly, usually unacceptable. Same thing if the resulting image is too small.

Some good results in enlargements can be obtained by using fractal compression, but this technology is not commonly accessible: http://en.wikipedia.org/wiki/Fractal_compression[^].

Resizing of images in .NET is easy. You only need to open original bitmap, create a new bitmap and draw the original bitmap on the new bitmap scaling it to the target size using appropriate System.Drawing.Graphics.DrawImage method:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawimage.aspx[^].

The instance of the class System.Drawing.Graphics for drawing is obtained from the target bitmap using this constructor: http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage.aspx[^].

That''s it.

—SA


这篇关于如何使用单个图像动态调整图像大小而不降低使用ASP.NET的图像质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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