zoukankan      html  css  js  c++  java
  • 通过Image对象获取对象的格式

    //strImgFilePath  图片文件名

    string GetImageFormat(string strImgFilePath)
            {
                string strImgFormat = "";
                System.Drawing.Image imgSrc = System.Drawing.Image.FromFile(strImgFilePath);

                if (imgSrc.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Jpeg))
                    strImgFormat = "jpeg";
                else if (imgSrc.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Gif))
                    strImgFormat = "gif";
                else if (imgSrc.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Bmp))
                    strImgFormat = "bmp";
                else if (imgSrc.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Png))
                    strImgFormat = "png";
                else if (imgSrc.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Tiff))
                    strImgFormat = "tiff";
                else if (imgSrc.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Icon))
                    strImgFormat = "icon";
                else if (imgSrc.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Wmf))
                    strImgFormat = "wmf";

    //可以再添加....

                return strImgFormat;

            }

    QQ:67042248

    天之道,利而不害;圣人之道,为而不争.

  • 相关阅读:
    python基础学习-无参装饰器
    python基础学习-day16==课后作业练习(函数对象和闭包)
    python基础学习-函数闭包
    python基础学习-函数对象与函数嵌套
    4.15作业
    反射、元类
    Mixins、多态、绑定方法与非绑定方法
    propety装饰器、继承
    封装
    4.8作业
  • 原文地址:https://www.cnblogs.com/kk1230/p/1567204.html
Copyright © 2011-2022 走看看