资源简介
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Threading;
namespace CompressImg
{
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
}
string ImgPath = ““;
ArrayList Mary = new ArrayList();
string ImgSavePath = ““;
Image ig = null;
private void Form1_Load(object sender EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;
}
///
/// 无损图片缩放
///
/// 图片的原始路径
/// 缩放后图片的保存路径
/// 缩放后图片的高度
/// 缩放后图片的宽度
///
public bool GetPicThumbnail(string sFile string dFile int dHeight int dWidth)
{
Image iSource = Image.FromFile(sFile);
ImageFormat tFormat = iSource.RawFormat;
int sW = 0 sH = 0;
// 按比例缩放
Size tem_size = new Size(iSource.WidthiSource.Height);
if (tem_size.Height> dHeight || tem_size.Width> dWidth)
{
if ((tem_size.Width * dHeight) > (tem_size.Height * dWidth))
{
sW = dWidth;
sH = (dWidth * tem_size.Height) / tem_size.Width;
}
else
{
sH = dHeight;
sW = (tem_size.Width * dHeight) / tem_size.Height;
}
}
else
{
sW = tem_size.Width;
sH = tem_size.Height;
}
Bitmap oB = new Bitmap(dWidth dHeight);
Graphics g = Graphics.FromImage(oB);
g.Clear(Color.WhiteSmoke);
// 设置画布的描绘质量
g.CompositingQuality = CompositingQuality.HighQuality;
g.SmoothingMode = SmoothingMode.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(iSource new Rectangle((dWidth - sW) / 2 (dHeight - sH) / 2 sW sH) 0 0 iSource.Width iSource.Height GraphicsUnit.Pixel);
g.Dispose();
// 以下代码为保存图片时,设置压缩质量
EncoderParameters eP = new EncoderParameters();
long[] qy = new long[1];
qy[0] = 100;
EncoderParameter eParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality qy);
eP.Param[0] = eParam;
try
{
//获得包含有关内置图像编码解码器的信息的ImageCodecInfo对象。
Ima
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 36864 2017-10-10 09:44 CompressImg\.vs\CompressImg\v14\.suo
文件 67646 2020-11-21 21:09 CompressImg\CompressImg\androzip_128px_1126105_easyicon.net.ico
文件 77 2019-11-08 09:33 CompressImg\CompressImg\app.config
文件 67646 2020-11-21 20:50 CompressImg\CompressImg\bin\Debug\androzip_128px_1126105_easyicon.net.ico
文件 202240 2020-12-27 13:56 CompressImg\CompressImg\bin\Debug\CompressImg.exe
文件 0 2020-11-21 21:34 CompressImg\CompressImg\bin\Debug\CompressImg.exe.CodeAnalysisLog.xm
文件 32256 2020-12-27 13:56 CompressImg\CompressImg\bin\Debug\CompressImg.pdb
文件 14328 2010-07-08 16:34 CompressImg\CompressImg\bin\Debug\CompressImg.vshost.exe
文件 490 2009-06-11 05:14 CompressImg\CompressImg\bin\Debug\CompressImg.vshost.exe.manifest
文件 25040 2020-11-21 21:01 CompressImg\CompressImg\bin\Debug\question_mark_481px_1291259_easyicon.net.png
文件 4290 2020-11-21 21:09 CompressImg\CompressImg\CompressImg.csproj
文件 477 2019-11-08 09:33 CompressImg\CompressImg\CompressImg.csproj.user
文件 10161 2020-12-07 16:44 CompressImg\CompressImg\Frm_Main.cs
文件 22528 2020-12-07 16:01 CompressImg\CompressImg\Frm_Main.Designer.cs
文件 170893 2020-12-07 16:01 CompressImg\CompressImg\Frm_Main.resx
文件 10198 2020-12-27 13:56 CompressImg\CompressImg\obj\Debug\CompressImg.csproj.FileListAbsolute.txt
文件 889 2020-12-27 13:56 CompressImg\CompressImg\obj\Debug\CompressImg.csproj.GenerateResource.Cache
文件 202240 2020-12-27 13:56 CompressImg\CompressImg\obj\Debug\CompressImg.exe
文件 180 2008-12-27 10:40 CompressImg\CompressImg\obj\Debug\CompressImg.Form1.resources
文件 110426 2020-12-27 13:56 CompressImg\CompressImg\obj\Debug\CompressImg.Frm_Main.resources
文件 32256 2020-12-27 13:56 CompressImg\CompressImg\obj\Debug\CompressImg.pdb
文件 3597 2020-12-27 13:56 CompressImg\CompressImg\obj\Debug\CompressImg.Properties.Resources.resources
文件 1371 2019-11-08 09:17 CompressImg\CompressImg\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7365 2020-11-21 21:09 CompressImg\CompressImg\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 4608 2013-11-13 13:32 CompressImg\CompressImg\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
文件 495 2020-11-16 16:30 CompressImg\CompressImg\Program.cs
文件 1410 2019-11-08 09:43 CompressImg\CompressImg\Properties\AssemblyInfo.cs
文件 3250 2013-11-13 13:32 CompressImg\CompressImg\Properties\Resources.Designer.cs
文件 6207 2008-10-13 09:17 CompressImg\CompressImg\Properties\Resources.resx
文件 1111 2013-11-13 13:32 CompressImg\CompressImg\Properties\Settings.Designer.cs
............此处省略20个文件信息
相关资源
- 输入框自动切换中文(C#winform)vs20
- C# OutlookBar导航菜单控件
- WPF鼠标拖动控件源码
- C#控件美化(TabControlEx)
- 网吧管理系统(包附数据库)
- winform右下角弹窗
- C# 定时提醒器
- C#实现 带列的树控件
- C# .NET5.0(net core)基于WPF(XAML)开发
- wpf echart
- C# 抽奖系统源码
- C# 俄罗斯方块(winform)
- C# 贪吃蛇(winform)
- C# 五子棋(winform源码)
- C# 验证码识别
- wpf Dock window
- svg批量转jpg|png
- C# 带跟随窗体的 CenterDialog
- C# 停车场项目(源码)
- C#计算异或和,ASCII码转十六进制
- C#USB开发
- C#通用类基础
- C#与西门子1500通讯59060
- C#摄像头调用
- C#唤起微信刷脸支付摄像头
- TCP通信(支持发送文本和图片文件)
- C#实现串口上位机
- C# 斑马手持终端WINCE开发 MC32N0 vs2008
- .net core 动态生成 Word文档(word Expor
- C#语言下MAF扩展框架应用完整
评论
共有 条评论