//value is the fullsize image byte array
_fullLectureImage = (byte[])value;
System.Drawing.Image htmlImage = ByteArrayToImage(_fullLectureImage);
System.Drawing.Image thumnailImage = htmlImage.GetThumbnailImage(_imageWidth, _imageHeight, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
this.Page.Session[_thumbnailImage] = ImageToByteArray(thumnailImage);
///
/// Returns System.Drawing.Image from byte array.
///
/// array of byte
///
private static System.Drawing.Image ByteArrayToImage(byte[] byteArrayIn)
{
MemoryStream memoryStream = new MemoryStream(byteArrayIn);
System.Drawing.Image returnImage = System.Drawing.Image.FromStream(memoryStream);
return returnImage;
}
///
/// Returns byte array from System.Drawing.Image.
///
/// System.Drawing.Image
///
private static byte[] ImageToByteArray(System.Drawing.Image imageIn)
{
MemoryStream memoryStream = new MemoryStream();
imageIn.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
return memoryStream.ToArray();
}
No comments:
Post a Comment