static private GetFormat ( |
||
format | ||
return | MagickFormat |
internal static MagickFormat GetFormat(ImageFormat format)
{
if (format == ImageFormat.Bmp)
return MagickFormat.Bmp;
else if (format == ImageFormat.Gif)
return MagickFormat.Gif;
else if (format == ImageFormat.Icon)
return MagickFormat.Icon;
else if (format == ImageFormat.Jpeg)
return MagickFormat.Jpeg;
else if (format == ImageFormat.Png)
return MagickFormat.Png;
else if (format == ImageFormat.Tiff)
return MagickFormat.Tiff;
else
throw new NotSupportedException("Unsupported image format: " + format.ToString());
}
}
/// <summary> /// Converts this instance to a <see cref="Bitmap"/> using the specified <see cref="ImageFormat"/>. /// Supported formats are: Bmp, Gif, Icon, Jpeg, Png, Tiff. /// </summary> /// <param name="imageFormat">The image format.</param> /// <returns>A <see cref="Bitmap"/> that has the specified <see cref="ImageFormat"/></returns> public Bitmap ToBitmap(ImageFormat imageFormat) { Format = MagickFormatInfo.GetFormat(imageFormat); MemoryStream memStream = new MemoryStream(); Write(memStream); memStream.Position = 0; /* Do not dispose the memStream, the bitmap owns it. */ return(new Bitmap(memStream)); }