• 大小: 0.28M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-05-02
  • 语言: C#
  • 标签: 压缩  C#  图片  

资源简介


资源截图

代码片段和文件信息

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.xml

     文件      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个文件信息

评论

共有 条评论