public System.Drawing.Image GetReducedImage(int Width, int Height, byte[] streamByte)
{
try
{
System.Drawing.Image ReducedImage;
System.IO.MemoryStream ms = new System.IO.MemoryStream(streamByte);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
System.Drawing.Image.GetThumbnailImageAbort callb = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
ReducedImage = img.GetThumbnailImage(Width, Height, callb, IntPtr.Zero);
return ReducedImage;
}
catch
{
return null;
}
}
public bool ThumbnailCallback()
{
return false;
}
这段代码展示了如何从二进制流中创建图片的缩略图。通过MemoryStream解析byte数组,然后利用System.Drawing.Image的GetThumbnailImage方法生成指定尺寸的缩略图,同时提供了回调函数用于中断缩略图生成过程。
220

被折叠的 条评论
为什么被折叠?



