/// <summary>Renders a thumbnail image.</summary> /// <param name="bitmap32">The bitmap32.</param> /// <param name="thumbFileName">Name of the thumbnail file to save to.</param> /// <param name="type">The type.</param> /// <returns></returns> public static byte[] RenderThumb(Bitmap32 bitmap32, string thumbFileName, ImageType type = ImageType.Jpeg) { bitmap32.LogDebug("Creating new thumbnail {0}", thumbFileName); using (var thumbImageStream = new MemoryStream()) using (var thumbBitmap = bitmap32.Resize(300, 300, ResizeMode.TouchFromInside)) { thumbBitmap.Save(thumbImageStream, type, 50); byte[] data = thumbImageStream.ToArray(); Directory.CreateDirectory(Path.GetDirectoryName(thumbFileName)); File.WriteAllBytes(thumbFileName, data); return(data); } }