/// <summary> /// Read single image frame. /// </summary> /// <param name="self">The image.</param> /// <param name="bitmap">The bitmap to read the image from.</param> /// <typeparam name="TQuantumType">The quantum type.</typeparam> /// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception> public static void Read <TQuantumType>(this IMagickImage <TQuantumType> self, Bitmap bitmap) where TQuantumType : struct { Throw.IfNull(nameof(self), self); Throw.IfNull(nameof(bitmap), bitmap); using (var memStream = new MemoryStream()) { if (IsSupportedImageFormat(bitmap.RawFormat)) { bitmap.Save(memStream, bitmap.RawFormat); } else { bitmap.Save(memStream, ImageFormat.Bmp); } memStream.Position = 0; self.Read(memStream); } }