/// <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)); }
/// <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> /// <param name="bitmapDensity">The bitmap density.</param> /// <returns>A <see cref="Bitmap"/> that has the specified <see cref="ImageFormat"/>.</returns> public Bitmap ToBitmap(ImageFormat imageFormat, BitmapDensity bitmapDensity) { Format = MagickFormatInfo.GetFormat(imageFormat); MemoryStream memStream = new MemoryStream(); Write(memStream); memStream.Position = 0; /* Do not dispose the memStream, the bitmap owns it. */ var bitmap = new Bitmap(memStream); SetBitmapDensity(bitmap, bitmapDensity); return(bitmap); }
private void SetFormat(ImageFormat format) { SetFormat(MagickFormatInfo.GetFormat(format)); }