C#产生大图片的缩略图
C#产生大图片的缩略图,jpg格式的15M左右,9600*14000,希望大家提供,我邮箱542739787@qq.com,谢谢!...
C#产生大图片的缩略图,jpg格式的15M左右,9600*14000,希望大家提供,我邮箱542739787@qq.com,谢谢!
展开
2个回答
展开全部
/// <summary>
/// 保存缩略图
/// </summary>
/// <param name="oldImage">源图</param>
/// <param name="image">目标图</param>
/// <param name="name">保存路径</param>
public static void DrawImage(System.Drawing.Image oldImage, System.Drawing.Image image,string name)
{
Graphics g = Graphics.FromImage(image);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.Clear(Color.White);
g.DrawImage(oldImage,new Rectangle(0,0,image.Width,image.Height) ,new Rectangle(0,0,oldImage.Width,oldImage.Height),GraphicsUnit.Pixel);
image.Save(name,System.Drawing.Imaging.ImageFormat.Jpeg);
g.Dispose();
image.Dispose();
}
先创建一张画板再进行绘图可以缩小图片所用内存,第二个参数image就是你上面通过代码
System.Drawing.Image thumImg = bigImg.GetThumbnailImage(350, 260, null, System.IntPtr.Zero);
thumImg.Save(Server.MapPath("/img/s2/") + filename);
System.Drawing.Image thumImg2 = bigImg.GetThumbnailImage(150, 150, null, System.IntPtr.Zero);
得到的两个image对象
/// 保存缩略图
/// </summary>
/// <param name="oldImage">源图</param>
/// <param name="image">目标图</param>
/// <param name="name">保存路径</param>
public static void DrawImage(System.Drawing.Image oldImage, System.Drawing.Image image,string name)
{
Graphics g = Graphics.FromImage(image);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.Clear(Color.White);
g.DrawImage(oldImage,new Rectangle(0,0,image.Width,image.Height) ,new Rectangle(0,0,oldImage.Width,oldImage.Height),GraphicsUnit.Pixel);
image.Save(name,System.Drawing.Imaging.ImageFormat.Jpeg);
g.Dispose();
image.Dispose();
}
先创建一张画板再进行绘图可以缩小图片所用内存,第二个参数image就是你上面通过代码
System.Drawing.Image thumImg = bigImg.GetThumbnailImage(350, 260, null, System.IntPtr.Zero);
thumImg.Save(Server.MapPath("/img/s2/") + filename);
System.Drawing.Image thumImg2 = bigImg.GetThumbnailImage(150, 150, null, System.IntPtr.Zero);
得到的两个image对象
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询