使用C#调整图像大小 [英] Resizing Image using C#

查看:107
本文介绍了使用C#调整图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调整文件夹中的图像大小。我使用的代码是这个



Hi, I am trying to resize an image in a folder. The code am using is this

string logoUrl = HttpContext.Current.Server.MapPath("DeviceLogo");
                System.Drawing.Image SourceLogo = System.Drawing.Image.FromFile(logoUrl + @"\" + objDevice.FileName);

                //Create a logo for this device and reseller/client business              
                Bitmap newImage = new Bitmap(objDevice.LogoWidth, objDevice.LogoHeight, PixelFormat.Format24bppRgb);
                using (Graphics graphics = Graphics.FromImage(newImage))
                {
                    graphics.CompositingQuality = CompositingQuality.HighQuality;
                    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    graphics.SmoothingMode = SmoothingMode.HighQuality;
                    graphics.DrawImage(SourceLogo, 0, 0, objDevice.LogoWidth, objDevice.LogoHeight);
                }
                string filepath = HttpContext.Current.Server.MapPath("DeviceLogo");                

                //Save the resized image                
                newImage.Save(filepath + objDevice.FileName);





但它没有工作。图像没有调整大小可以任意请帮助!!



But its not working.The image is not getting resized Can anyine please help!!

推荐答案

参考一些CP文章:

C#:图像调整大小,转换和保存 [ ^ ]

使用C#动态调整图像大小 [ ^ ]
Refer some CP articles:
C#: Image resize, convert, and save[^]
Resizing image dynamically using C#[^]


这篇关于使用C#调整图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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