在C#中,图像缩放后如何返回一个Image类的值?
1个回答
展开全部
image.GetThumbnailImage() 方法返回的还是Image类型,具体看以下示例代码
private Image GetThumbnail(string base64String, int width, int height)
{
byte[] imageBytes = Convert.FromBase64String(base64String);
MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);
// Convert byte[] to Image
ms.Write(imageBytes, 0, imageBytes.Length);
Image image = Image.FromStream(ms, true);
Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
Image thumbnail = image.GetThumbnailImage(width, height, myCallback, IntPtr.Zero);
ms.Close();
ms.Dispose();
image.Dispose();
return thumbnail;
}
public bool ThumbnailCallback()
{
return false;
}
private Image GetThumbnail(string base64String, int width, int height)
{
byte[] imageBytes = Convert.FromBase64String(base64String);
MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);
// Convert byte[] to Image
ms.Write(imageBytes, 0, imageBytes.Length);
Image image = Image.FromStream(ms, true);
Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
Image thumbnail = image.GetThumbnailImage(width, height, myCallback, IntPtr.Zero);
ms.Close();
ms.Dispose();
image.Dispose();
return thumbnail;
}
public bool ThumbnailCallback()
{
return false;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询