| using System.IO; |
| using IronSoftware.Drawing; |
| |
| namespace OfficeOpenXml.Compatibility |
| { |
| internal class ImageCompat |
| { |
| internal static byte[] GetImageAsByteArray(AnyBitmap image) |
| { |
| var ms = new MemoryStream(); |
| if (image.GetImageFormat() == AnyBitmap.ImageFormat.Gif || |
| image.GetImageFormat() == AnyBitmap.ImageFormat.Bmp || |
| image.GetImageFormat() == AnyBitmap.ImageFormat.Png || |
| image.GetImageFormat() == AnyBitmap.ImageFormat.Tiff) |
| { |
| image.ExportStream(ms, image.GetImageFormat()); |
| } |
| else |
| { |
| image.ExportStream(ms, AnyBitmap.ImageFormat.Jpeg); |
| } |
| |
| return ms.ToArray(); |
| } |
| } |
| } |