Get Image Encoder from ImageFormat - CSharp System.Drawing.Imaging

CSharp examples for System.Drawing.Imaging:ImageFormat

Description

Get Image Encoder from ImageFormat

Demo Code


using System.Linq;
using System.Threading.Tasks;
using System.Drawing.Imaging;
using System.Drawing;
using System.Collections.Generic;
using System;/*from   w w  w .  jav a2  s  .  co  m*/

public class Main{
        static ImageCodecInfo GetEncoder(ImageFormat format)
        {
            ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
            return codecs.Single(codec => codec.FormatID == format.Guid);
        }
}

Related Tutorials