360教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

用C#简单在DOTNET中完成缩略图

时间:2024/7/17作者:未知来源:360教程人气:

[摘要](num < 1)) return; //用指定的大小和格式初始化 Bitmap 类的新实例 Bitmap bitmap = new Bitmap(Thumbnail...
(num < 1))
   {
    return;
   }
   //用指定的大小和格式初始化 Bitmap 类的新实例
   Bitmap bitmap = new Bitmap(ThumbnailImageWidth, num, PixelFormat.Format32bppArgb);
   //从指定的 Image 对象创建新 Graphics 对象
   Graphics graphics = Graphics.FromImage(bitmap);
   //清除整个绘图面并以透明背景色填充
   graphics.Clear(Color.Transparent);
   //在指定位置并且按指定大小绘制 原图片 对象
   graphics.DrawImage(image, new Rectangle(0, 0, ThumbnailImageWidth, num));
   image.Dispose();    
   try
   {   
    //将此 原图片 以指定格式并用指定的编解码参数保存到指定文件
    string savepath = (ThumbnailImagePath==null?SourceImagePath:ThumbnailImagePath);  
    SaveImage(bitmap,HttpContext.Current.Server.MapPath(savepath),GetCodecInfo((string)htmimes

[sExt]));
   }
   catch(System.Exception e)
   {
    throw e;
   }
   finally
   {
    bitmap.Dispose();      
    graphics.Dispose();
   }
  }
  #endregion

}
}

关键词:用C#简单在DOTNET中完成缩略图




Copyright © 2012-2018 360教程(http://www.360sd.cn) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版