当前位置: 首页>>代码示例>>C#>>正文


C# ImageFormat.Equals方法代码示例

本文整理汇总了C#中System.Drawing.Imaging.ImageFormat.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# ImageFormat.Equals方法的具体用法?C# ImageFormat.Equals怎么用?C# ImageFormat.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Imaging.ImageFormat的用法示例。


在下文中一共展示了ImageFormat.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTinytImageFormat

        private Byte GetTinytImageFormat(
            ImageFormat rawFormat)
        {
            if (rawFormat.Equals(ImageFormat.Gif))
            {
                return 1;
            }
            
            if (rawFormat.Equals(ImageFormat.Jpeg))
            {
                return 2;
            }

            return 0;
        }
开发者ID:Roddoric,项目名称:Monkey.Robotics,代码行数:15,代码来源:TinyBitmapProcessor.cs

示例2: GetSaveFormat

 private static SaveFormat GetSaveFormat(ImageFormat imageFormat)
 {
     SaveFormat sf = SaveFormat.Unknown;
     if (imageFormat.Equals(ImageFormat.Png))
         sf = SaveFormat.Png;
     else if (imageFormat.Equals(ImageFormat.Jpeg))
         sf = SaveFormat.Jpeg;
     else if (imageFormat.Equals(ImageFormat.Tiff))
         sf = SaveFormat.Tiff;
     else if (imageFormat.Equals(ImageFormat.Bmp))
         sf = SaveFormat.Bmp;
     else
         sf = SaveFormat.Unknown;
     return sf;
 }
开发者ID:alqadasifathi,项目名称:OfficeTools.Pdf2Image.Word2Image,代码行数:15,代码来源:Program.cs

示例3: SaveBitmap

 public static void SaveBitmap(Bitmap bitmap, string fileName, ImageFormat imageFormat)
 {
     if (imageFormat.Equals(ImageFormat.Gif)) {
         SaveGif(bitmap, fileName);
     }
     else if (imageFormat.Equals(ImageFormat.Tiff)) {
         SaveTIFF(bitmap, fileName);
     }
     else if (imageFormat.Equals(ImageFormat.Jpeg)) {
         SaveJpeg(bitmap, fileName, 80);
     }
     else {
         bitmap.Save(fileName, imageFormat);
     }
 }
开发者ID:petergolde,项目名称:PurplePen,代码行数:15,代码来源:BitmapUtil.cs

示例4: GetImageMimeType

		public static string GetImageMimeType (ImageFormat format)
		{
			string mimeType = "image/x-unknown";

			if (format.Equals (ImageFormat.Gif))
			{
				mimeType = "image/gif";
			}
			else if (format.Equals (ImageFormat.Jpeg))
			{
				mimeType = "image/jpeg";
			}
			else if (format.Equals (ImageFormat.Png))
			{
				mimeType = "image/png";
			}
			else if (format.Equals (ImageFormat.Bmp) || format.Equals (ImageFormat.MemoryBmp))
			{
				mimeType = "image/bmp";
			}
			else if (format.Equals (ImageFormat.Tiff))
			{
				mimeType = "image/tiff";
			}
			else if (format.Equals (ImageFormat.Icon))
			{
				mimeType = "image/x-icon";
			}

			return mimeType;
		}
开发者ID:roman-yagodin,项目名称:R7.ImageHandler,代码行数:31,代码来源:Utils.cs

示例5: ScreenShot

 /// <summary>
 /// コンストラクタ。
 /// </summary>
 public ScreenShot()
 {
     _dir = Option.Instance().SaveDirectory;
     _fileFmt = Option.Instance().FileNameFormat;
     _imgFmt = Option.Instance().ImageFormat;
     // 拡張子を設定する。Jpegの場合は"jpg"、それ以外は名称をそのままに小文字に変換している。
     _ext = _imgFmt.Equals(ImageFormat.Jpeg) ? "jpg" : _imgFmt.ToString().ToLower();
     _matches = Rx.Matches(_fileFmt);
 }
开发者ID:rabbitka,项目名称:RabiShot,代码行数:12,代码来源:ScreenShot.cs

示例6: ImageFormatToExtension

 // Taken from http://www.java2s.com/Code/CSharp/File-Stream/ImageFormattoExtension.htm
 // And modified.
 public static string ImageFormatToExtension(ImageFormat imageFormat)
 {
     if (imageFormat.Equals(ImageFormat.Bmp))
     {
         return "BMP";
     }
     else if (imageFormat.Equals(ImageFormat.MemoryBmp))
     {
         return "BMP";
     }
     else if (imageFormat.Equals(ImageFormat.Wmf))
     {
         return "EMF";
     }
     else if (imageFormat.Equals(ImageFormat.Wmf))
     {
         return "WMF";
     }
     else if (imageFormat.Equals(ImageFormat.Gif))
     {
         return "GIF";
     }
     else if (imageFormat.Equals(ImageFormat.Jpeg))
     {
         return "JPG";
     }
     else if (imageFormat.Equals(ImageFormat.Png))
     {
         return "PNG";
     }
     else if (imageFormat.Equals(ImageFormat.Tiff))
     {
         return "TIF";
     }
     else if (imageFormat.Equals(ImageFormat.Exif))
     {
         return "EXF";
     }
     else if (imageFormat.Equals(ImageFormat.Icon))
     {
         return "ICO";
     }
     return "";
 }
开发者ID:sahands,项目名称:a-id3,代码行数:46,代码来源:ImagingHelpers.cs

示例7: ToContentType

 public static string ToContentType(ImageFormat imageFormat)
 {
     if (imageFormat.Equals(ImageFormat.Bmp)) return "image/bmp";
     if (imageFormat.Equals(ImageFormat.Gif)) return "image/gif";
     if (imageFormat.Equals(ImageFormat.Icon)) return "image/vnd.microsoft.icon";
     if (imageFormat.Equals(ImageFormat.Jpeg)) return "image/jpeg";
     if (imageFormat.Equals(ImageFormat.Png)) return "image/png";
     if (imageFormat.Equals(ImageFormat.Tiff)) return "image/tiff";
     if (imageFormat.Equals(ImageFormat.Wmf)) return "image/wmf";
     return "image/bmp";
 }
开发者ID:jdaigle,项目名称:SimpleBlog,代码行数:11,代码来源:ImageResult.cs

示例8: FromImageFormat

		public static ImageFormatInfo FromImageFormat(ImageFormat format)
		{
			if (format.Equals(ImageFormat.Bmp) || format.Equals(ImageFormat.MemoryBmp))
				return Bmp;
			if (format.Equals(ImageFormat.Emf))
				return Emf;
			if (format.Equals(ImageFormat.Wmf))
				return Wmf;
			if (format.Equals(ImageFormat.Exif))
				return Exif;
			if (format.Equals(ImageFormat.Gif))
				return Gif;
			if (format.Equals(ImageFormat.Icon))
				return Icon;
			if (format.Equals(ImageFormat.Jpeg))
				return Jpeg;
			if (format.Equals(ImageFormat.Png))
				return Png;
			if (format.Equals(ImageFormat.Tiff))
				return Tiff;
			return Bmp;
		}
开发者ID:rsdn,项目名称:janus,代码行数:22,代码来源:ImageFormatInfo.cs

示例9: GetMimeType

 internal static string GetMimeType(ImageFormat imgFormat)
 {
     if (imgFormat.Equals(ImageFormat.Jpeg)) {
         return "image/jpeg";
     } else if (imgFormat.Equals(ImageFormat.Png)) {
         return "image/png";
     } else if (imgFormat.Equals(ImageFormat.Bmp)) {
         return "image/bmp";
     } else if (imgFormat.Equals(ImageFormat.Gif)) {
         return "image/gif";
     } else if (imgFormat.Equals(ImageFormat.Tiff)) {
         return "image/tiff";
     } else if (imgFormat.Equals(ImageFormat.Icon)) {
         return "image/x-icon";
     } else {
         return "image/";
     }
 }
开发者ID:IljaN,项目名称:BPRename,代码行数:18,代码来源:FrameUtil.cs

示例10: GetImageFormat

 public ImageFormat GetImageFormat(ImageFormat format)
 {
     if (format.Equals(ImageFormat.Jpeg))
         return ImageFormat.Jpeg;
     if (format.Equals(ImageFormat.Bmp))
         return ImageFormat.Bmp;
     if (format.Equals(ImageFormat.Png))
         return ImageFormat.Png;
     if (format.Equals(ImageFormat.Emf))
         return ImageFormat.Emf;
     if (format.Equals(ImageFormat.Exif))
         return ImageFormat.Exif;
     if (format.Equals(ImageFormat.Gif))
         return ImageFormat.Gif;
     if (format.Equals(ImageFormat.Icon))
         return ImageFormat.Icon;
     if (format.Equals(ImageFormat.MemoryBmp))
         return ImageFormat.MemoryBmp;
     if (format.Equals(ImageFormat.Tiff))
         return ImageFormat.Tiff;
     return ImageFormat.Wmf;
 }
开发者ID:PictoCrypt,项目名称:ImageTools,代码行数:22,代码来源:FileManager.cs

示例11: GetImagePartType

 /// <summary>
 /// Gets the image type representation for a mimetype
 /// </summary>
 /// <param name="format">Content mimetype</param>
 /// <returns>Image type</returns>
 private static ImagePartType GetImagePartType(ImageFormat format)
 {
     if (format.Equals(ImageFormat.Jpeg))
         return ImagePartType.Jpeg;
     else if (format.Equals(ImageFormat.Emf))
         return ImagePartType.Emf;
     else if (format.Equals(ImageFormat.Gif))
         return ImagePartType.Gif;
     else if (format.Equals(ImageFormat.Icon))
         return ImagePartType.Icon;
     else if (format.Equals(ImageFormat.Png))
         return ImagePartType.Png;
     else if (format.Equals(ImageFormat.Tiff))
         return ImagePartType.Tiff;
     else if (format.Equals(ImageFormat.Wmf))
         return ImagePartType.Wmf;
     else
         return ImagePartType.Bmp;
 }
开发者ID:jecabana,项目名称:Portal-Vanity-Daniel-en-stand-by,代码行数:24,代码来源:PictureAccessor.cs

示例12: Resize

        private static byte[] Resize( Size newSize, bool keepAspectRatio, Image image, ImageFormat outputFormat )
        {
            if (image == null)
                return null;

            Size cropSize = newSize;
            Size orginalSize = image.Size;

            //Calculate scale/Crop ratios
            if (!keepAspectRatio)
            {
                float scaleWidth = (float)newSize.Width / orginalSize.Width;
                float scaleHeight = (float)newSize.Height / orginalSize.Height;

                //Not proportional scale
                if (scaleWidth != scaleHeight)
                {
                    if (scaleHeight > scaleWidth)
                    {
                        newSize.Width = (int)(scaleHeight * orginalSize.Width);
                    }
                    else
                    {
                        newSize.Height = (int)(scaleWidth * orginalSize.Height);
                    }
                }
                else
                {
                    keepAspectRatio = true;
                }
            }

            try
            {
                using (MemoryStream ms = new MemoryStream ())
                {
                    using (Bitmap bmPhoto = new Bitmap (newSize.Width, newSize.Height, PixelFormat.Format24bppRgb))
                    {
                        bmPhoto.SetResolution (image.HorizontalResolution, image.VerticalResolution);

                        if (outputFormat.Equals (ImageFormat.Png))
                            bmPhoto.MakeTransparent ();

                        using (Graphics grPhoto = Graphics.FromImage (bmPhoto))
                        {
                            grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;
                            grPhoto.SmoothingMode = SmoothingMode.HighQuality;
                            grPhoto.PixelOffsetMode = PixelOffsetMode.HighQuality;
                            grPhoto.CompositingQuality = CompositingQuality.HighQuality;

                            if (outputFormat.Equals (ImageFormat.Png))
                                grPhoto.FillRectangle (Brushes.Transparent, 0, 0, newSize.Width, newSize.Height);
                            else
                                grPhoto.FillRectangle (Brushes.White, 0, 0, newSize.Width, newSize.Height);

                            // Use wrap mode in order to get rid of the unwanted border around the image
                            using (ImageAttributes wrapMode = new ImageAttributes ())
                            {
                                wrapMode.SetWrapMode (WrapMode.TileFlipXY);
                                Rectangle rectangle = new Rectangle (0, 0, newSize.Width, newSize.Height);
                                grPhoto.DrawImage (image, rectangle, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
                            }
                        }

                        if (!keepAspectRatio && !cropSize.Equals (newSize))
                        {
                            int widthToCrop = Math.Max (0, (newSize.Width - cropSize.Width) / 2);
                            int heigthToCrop = Math.Max (0, (newSize.Height - cropSize.Height) / 2);

                            using (Bitmap bmpCrop = new Bitmap (cropSize.Width, cropSize.Height, PixelFormat.Format24bppRgb))
                            {
                                bmPhoto.SetResolution (image.HorizontalResolution, image.VerticalResolution);

                                if (outputFormat.Equals (ImageFormat.Png))
                                    bmpCrop.MakeTransparent ();

                                using (Graphics gfx = Graphics.FromImage (bmpCrop))
                                {
                                    Rectangle source = new Rectangle (widthToCrop, heigthToCrop, cropSize.Width, cropSize.Height);
                                    Rectangle target = new Rectangle (0, 0, bmpCrop.Width, bmpCrop.Height);

                                    if (outputFormat.Equals (ImageFormat.Png))
                                        gfx.FillRectangle (Brushes.Transparent, 0, 0, newSize.Width, newSize.Height);
                                    else
                                        gfx.FillRectangle (Brushes.White, 0, 0, newSize.Width, newSize.Height);

                                    gfx.DrawImage (bmPhoto, target, source, GraphicsUnit.Pixel);
                                    GetImageStream (outputFormat, bmpCrop, ms);
                                }
                            }
                        }
                        else
                        {
                            GetImageStream (outputFormat, bmPhoto, ms);
                        }
                    }
                    return ms.ToArray ();
                }
            }
            catch (Exception e)
//.........这里部分代码省略.........
开发者ID:andriybilas,项目名称:MasterM,代码行数:101,代码来源:ScalableImageUtility.cs

示例13: SaveImageToDisk

        /// <summary>
        /// Persist the specified image to disk at the specified path. If the directory to contain the file does not exist, it
        /// is automatically created.
        /// </summary>
        /// <param name="image">The image to persist to disk.</param>
        /// <param name="newFilePath">The full physical path, including the file name to where the image is to be stored. Ex: C:\mypics\cache\2008\May\flower.jpg</param>
        /// <param name="imageFormat">The file format for the image.</param>
        /// <param name="jpegQuality">The quality value to save JPEG images at. This is a value between 1 and 100. This parameter
        /// is ignored if the image format is not JPEG.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="imageFormat" /> is null.</exception>
        public static void SaveImageToDisk(System.Drawing.Image image, string newFilePath, ImageFormat imageFormat, int jpegQuality)
        {
            if (imageFormat == null)
                throw new ArgumentNullException("imageFormat");

            VerifyDirectoryExistsForNewFile(newFilePath);

            if (imageFormat.Equals(ImageFormat.Jpeg))
                SaveJpgImageToDisk(image, newFilePath, jpegQuality);
            else
                SaveNonJpgImageToDisk(image, newFilePath, imageFormat);
        }
开发者ID:raquelsa,项目名称:GalleryServerProWeb,代码行数:22,代码来源:ImageHelper.cs

示例14: GetImageMime

 /// <summary>
 /// Get MIME type corresponding to given <paramref name="format"/>.
 /// </summary>
 /// <param name="format"></param>
 /// <returns>MIME type of given <paramref name="format"/>.</returns>
 private static string GetImageMime(ImageFormat format)
 {
     if (format.Equals(ImageFormat.Gif))
         return "image/gif";
     else if (format.Equals(ImageFormat.Jpeg))
         return "image/jpeg";
     else if (format.Equals(ImageFormat.Png))
         return "image/png";
     else if (format.Equals(ImageFormat.Bmp))
         return "image/bmp";
     else if (format.Equals(ImageFormat.Icon))
         return "image/x-icon";
     else if (format.Equals(ImageFormat.Tiff))
         return "image/tiff";
     else if (format.Equals(ImageFormat.Emf))
         return "image/x-emf"; // Windows Metafile
     else if (format.Equals(ImageFormat.Wmf))
         return "image/x-wmf"; // Windows Metafile
     else if (format.Equals(ImageFormat.Exif))
         return "image/jpeg";    // should it be even handled ?
     else
         throw new NotImplementedException();
 }
开发者ID:Ashod,项目名称:Phalanger,代码行数:28,代码来源:PhpImage.cs

示例15: ImageFormatToMimeType

        /// <summary>
        /// Gets the MIME type from the image format.
        /// </summary>
        /// <param name="format">The image format.</param>
        /// <returns>the right MIME type.</returns>
        internal string ImageFormatToMimeType(ImageFormat format)
        {
            if (null == format)
            {
                throw new ArgumentNullException("format");
            }

            if (format.Equals(ImageFormat.Bmp) || format.Equals(ImageFormat.MemoryBmp))
            {
                return "image/bmp";
            }
            else if (format.Equals(ImageFormat.Emf))
            {
                return "image/x-emf";
            }
            else if (format.Equals(ImageFormat.Gif))
            {
                return "image/gif";
            }
            else if (format.Equals(ImageFormat.Jpeg))
            {
                return "image/jpeg";
            }
            else if (format.Equals(ImageFormat.Png))
            {
                return "image/x-png";
            }
            else if (format.Equals(ImageFormat.Tiff))
            {
                return "image/tiff";
            }
            else if (format.Equals(ImageFormat.Wmf))
            {
                return "image/x-wmf";
            }

            throw new NotSupportedException();
        }
开发者ID:fmendes,项目名称:RegisterJavascript,代码行数:43,代码来源:DynamicImageProvider.cs


注:本文中的System.Drawing.Imaging.ImageFormat.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。