zoukankan      html  css  js  c++  java
  • TIF转JPG

     public void TifToJpg(string tifPath, string tifName)
            {
                try
                {
                    //找到后缀为TIF的图像,如果没有,就catch退出
                    int len = tifPath.ToUpper().LastIndexOf(".TIF");
                    if (len > 0)
                    {
                        //去掉文件后缀名后的路径
                        string fileName2 = tifPath.Substring(0, len);
                        //得到父路径
                        string filePath = fileName2.Substring(0, fileName2.LastIndexOf('\') + 1);
                        //使用文件流获取这个文件
                        FileStream stream = File.OpenRead(tifPath);
                        //像素类初始化图像
                        Bitmap bmp = new Bitmap(stream);
                        //处理图像的过程
                        // 获取该 System.Drawing.Image 的像素数据的特性标志。
                        System.Drawing.Image image = bmp;
                        Guid objGuid = image.FrameDimensionsList[0];
                        //提供获取图像的框架维度的属性。不可继承。
                        FrameDimension objDimension = new FrameDimension(objGuid);
                        int totFrame = image.GetFrameCount(objDimension);
                        //循环处理贞
                        for (int i = 0; i < totFrame; i++)
                        {
                            image.SelectActiveFrame(objDimension, i);
                            image.Save(filePath + tifName + ".jpg", ImageFormat.Jpeg);
                        }
                        bmp.Dispose();
                        image.Dispose();
                        stream.Close();
                        ////删掉以前的图片
                        //File.Delete(tifPath);
                    }
    
                }
                catch (Exception)
                {
    
                }
            } 
  • 相关阅读:
    poj 2312 Battle City
    poj 2002 Squares
    poj 3641 Pseudoprime numbers
    poj 3580 SuperMemo
    poj 3281 Dining
    poj 3259 Wormholes
    poj 3080 Blue Jeans
    poj 3070 Fibonacci
    poj 2887 Big String
    poj 2631 Roads in the North
  • 原文地址:https://www.cnblogs.com/llcdbk/p/5101689.html
Copyright © 2011-2022 走看看