在Asp.net中调整图像大小c#动态 [英] Image Resizing in Asp.net c# Dynamically

查看:106
本文介绍了在Asp.net中调整图像大小c#动态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



我想将一个图像重新调整为多个尺寸的图像,如thumb_image(宽度48px高度64px),Small_image(宽度240px高度320px), big_image(宽度1080px高1440px)。我正在使用asp.net c#中的文件上传来上传图片。在提交按钮上我想动态创建上面的图像并保存在我的特定文件夹中。



请为我提供帮助或示例代码..



谢谢Advance

解决方案

检查这些代码项目链接



使用C#动态调整图像大小 [ ^ ]



动态调整上传图片的大小&以PNG格式保存 [ ^ ]


请查看以下站点中的代码: Link 1 [ ^ ]

Link 2 [ ^ ]

链接3 [ ^ ]

在你的上传控制中,为你的图像调用不同比率的这些方法。



祝你好运,

OI

 int NewWidth = 100; 
int NewHeight = 74;
// FileStream fs = File.Open(,FileMode.Open);
StreamReader sr = new StreamReader(HttpContext.Current.Server.MapPath(path)+ guid +。+ fileName.Split(''。'')[fileName.Split(''。'')。Length - 1]);
System.Drawing.Bitmap bmpOut = new System.Drawing.Bitmap(NewWidth,NewHeight);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmpOut);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.FillRectangle(System.Drawing.Brushes.White,0,0,NewWidth,NewHeight);
g.DrawImage(new System.Drawing.Bitmap(sr.BaseStream),0,0,NewWidth,NewHeight);
MemoryStream stream = new MemoryStream();

bmpOut.Save(stream,System.Drawing.Imaging.ImageFormat.Jpeg);

字符串saveImagePath = path + guid +_ _ thumbnail.jpg;
bmpOut.Save(HttpContext.Current.Server.MapPath(saveImagePath),System.Drawing.Imaging.ImageFormat.Jpeg);
g.Dispose();
bmpOut.Dispose();
sr.Dispose();



图像生成


Dear All,

I want re-size one image into Multiple size Images like thumb_image(Width 48px height 64px),Small_image(Width 240px height 320px),big_image(Width 1080px high 1440px). I am uploading image using File Upload in asp.net c#. on Submit button I want to create above size image dynamically & save in my specific folder.

Please provide me help or sample code for the same..

Thanks Advance

解决方案

check these codeproject links

Resizing image dynamically using C#[^]

Dynamically resize uploaded images & save in PNG format[^]


Please look at the codes in the following sites: Link 1[^]
Link 2[^]
Link 3[^]
In your upload control call these methods for different ratios for your images.

Good luck,
OI


int NewWidth = 100;
        int NewHeight = 74;
        // FileStream fs = File.Open(, FileMode.Open);
        StreamReader sr = new StreamReader(HttpContext.Current.Server.MapPath(path) + guid + "." + fileName.Split(''.'')[fileName.Split(''.'').Length - 1]);
        System.Drawing.Bitmap bmpOut = new System.Drawing.Bitmap(NewWidth, NewHeight);
        System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmpOut);
        g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
        g.FillRectangle(System.Drawing.Brushes.White, 0, 0, NewWidth, NewHeight);
        g.DrawImage(new System.Drawing.Bitmap(sr.BaseStream), 0, 0, NewWidth, NewHeight);
        MemoryStream stream = new MemoryStream();

        bmpOut.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);

        String saveImagePath = path + guid + "_thumbnail.jpg";
        bmpOut.Save(HttpContext.Current.Server.MapPath(saveImagePath), System.Drawing.Imaging.ImageFormat.Jpeg);
        g.Dispose();
        bmpOut.Dispose();
        sr.Dispose();


image geneation


这篇关于在Asp.net中调整图像大小c#动态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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