/// <summary>Creates a bitmap instance from the specified Bitmap32.</summary> public static Bitmap ToGdiBitmap(this IBitmap32 other) { if (other is GdiBitmap32) { return(((GdiBitmap32)other).Bitmap); } using var ms = new MemoryStream(); other.Save(ms); ms.Position = 0; return(ToGdiBitmap(Image.FromStream(ms))); }
/// <summary> /// Converts a bitmap /// </summary> /// <param name="bitmap"></param> /// <returns></returns> public static SKBitmap Convert(IBitmap32 bitmap) { if (bitmap is SkiaBitmap32) { return(((SkiaBitmap32)bitmap).bitmap); } using (MemoryStream ms = new MemoryStream()) { bitmap.Save(ms); ms.Position = 0; return(SKBitmap.Decode(ms)); } }
/// <summary>Saves the image to the specified stream.</summary> /// <param name="stream">The stream.</param> /// <param name="type">The type.</param> /// <param name="quality">The quality.</param> /// <exception cref="NotImplementedException"></exception> public virtual void Save(Stream stream, ImageType type = ImageType.Png, int quality = 100) { bitmap.Save(stream, type, quality); }