ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

GetImageCodecInfo

Gets the ImageCodecInfo that corresponds to a ImageFormat.

Source

public static ImageCodecInfo GetImageCodecInfo(this ImageFormat imageFormat)
{
	if(imageFormat == null)
		throw new ArgumentNullException("imageFormat");

	return ImageCodecInfo.GetImageEncoders().FirstOrDefault(i => i.Clsid == imageFormat.Guid);
}

Example

ImageCodecInfo codec = ImageFormat.Png.GetImageCodecInfo();

Author: Lucas

Submitted on: 7 mrt. 2008

Language: C#

Type: System.Drawing.Imaging.ImageFormat

Views: 4943