using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
namespace Phaeton.Helpers.ImageUtilities
{
///
/// General routines for image manipulating.
///
public static class ImageHelper
{
///
/// Saves the image to a bytes array. Used to store an image into DB.
///
/// Image.
/// Format to save the image with.
/// Byte array that represents the specified image.
public static byte[] GetBytes(Image image, ImageFormat imageFormat)
{
using (MemoryStream stream = new MemoryStream())
{
image.Save(stream, imageFormat);
byte[] bytes = new byte[stream.Length];
stream.Position = 0;
stream.Read(bytes, 0, bytes.Length);
return bytes;
}
}
}
}