c# - Image.GetThumbnailImage 方法和质量

标签 c# .net asp.net graphics

我在使用 Getthumbnailimage 时遇到问题。问题是特定大小的文件大小显示非常模糊和颗粒状。在msdn , 它说

The GetThumbnailImage method works well when the requested thumbnail image has a size of about 120 x 120 pixels. If you request a large thumbnail image (for example, 300 x 300) from an Image that has an embedded thumbnail, there could be a noticeable loss of quality in the thumbnail image. It might be better to scale the main image (instead of scaling the embedded thumbnail) by calling the DrawImage method.

问题是drawimage好像是windows窗体的。有没有办法在 Webforms 中做到这一点?这是我的代码的一部分。注意:我不想得到缩略图,这是别人写的,我只想显示实际大小,仅此而已。

protected void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
ad a=(ad)Session["a"];
     DataView dv=a.AdData.Tables[0].DefaultView;
dv.RowFilter="ad_nbr=" + Request.QueryString["l"].Trim();
byte[] MyData= new byte[0];
MyData =  (byte[])dv[0]["image"];
System.Web.HttpContext.Current.Response.ContentType = "image/jpeg";     System.Drawing.Image _image = System.Drawing.Image.FromStream(new  stem.IO.MemoryStream( (byte[])dv[0]["image"]) );

System.Drawing.Image _newimage = _image.GetThumbnailImage(_image.Width, _image.Height,    null, new System.IntPtr() );

        _newimage.Save( System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg );

    }

最佳答案

如果您想更好地控制所获得产品的质量(尤其是更好的质量),take a look at resizing using this method .涉及的工作有点多,但结果比 GetThumbnailImage 好得多。

此方法也适用于 Webforms。

关于c# - Image.GetThumbnailImage 方法和质量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7209891/

相关文章:

.net - SGEN、InternalsVisibleTo 和程序集签名

asp.net - css帮助,用div显示图像

c# - 视觉 C# "Could not load file or assembly or one of its dependencies"

c# - 使用 Roslyn,从字符串文字参数中找到调用方法

c# - 'where()' 方法的问题

.net - Linq 2 实体 : Performing a join on two columns with different types

c# - 为什么 Visual Studio 有时不转到我的断点?

c# - css在asp.net中的使用

c# - Unity如何序列化和反序列化复杂的嵌套json?

c# - 在 ASP.NET 问题中使用 jQuery AjaxForm