高清缩略图代码,可删除原图不会出现在XXX.jpg正在使用中,水印代正在研究中
我在网上用了很多的相关代码或者缩略图水印类,但是都有一个问题就是删除不了原图 public static void myGetThumbnailImage(string SourceFile, string strSavePathFile, int ThumbWidth, int ThumbHeight, string BgColor) { System.Drawing.Image oImg = System.Drawing.Image.FromFile(SourceFile); //小图 int intwidth, intheight; if (oImg.Width > oImg.Height) { if (oImg.Width > ThumbWidth) { intwidth = ThumbWidth; intheight = (oImg.Height * ThumbWidth) / oImg.Width; } else { intwidth = oImg.Width; intheight = oImg.Height; } } else { if (oImg.Height > ThumbHeight) { intwidth = (oImg.Width * ThumbHeight) / oImg.Height; intheight = ThumbHeight; } else { intwidth = oImg.Width; intheight = oImg.Height; } } //构造一个指定宽高的Bitmap Bitmap bitmay = new Bitmap(intwidth, intheight); Graphics g = Graphics.FromImage(bitmay); Color myColor; if (BgColor == null) myColor = Color.FromName("white"); else myColor = Color.FromName(BgColor); //用指定的颜色填充Bitmap g.Clear(myColor); g.InterpolationMode = InterpolationMode.HighQualityBicubic; //开始画图 g.DrawImage(oImg, new Rectangle(0, 0, intwidth, intheight), new Rectangle(0, 0, oImg.Width, oImg.Height), GraphicsUnit.Pixel); bitmay.Save(strSavePathFile, System.Drawing.Imaging.ImageFormat.Jpeg); g.Dispose(); bitmay.Dispose(); oImg.Dispose(); //删除源图 try { File.Delete(SourceFile); } catch { } }
- 1
- 粉丝: 71
- 资源: 8
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 论文(最终)_20240430235101.pdf
- 基于python编写的Keras深度学习框架开发,利用卷积神经网络CNN,快速识别图片并进行分类
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx