【发布时间】:2011-05-09 11:56:19
【问题描述】:
我正在尝试将图像转换为图标。我的功能是:
private Icon GenerateIcon(int width, int height)
{
using (Bitmap icon = _backingImage.GetThumbnailImage(width, height, () => false, System.IntPtr.Zero) as Bitmap)
using(MemoryStream imgStream = new MemoryStream())
{
icon.Save(imgStream, System.Drawing.Imaging.ImageFormat.Icon);
return new Icon(imgStream);
}
}
但是当程序调用该方法时,它会抛出一个ArgumentNullException("encoder") 我正在调用icon.Save。
我觉得这很奇怪,因为我没有传递编码器,我希望框架弄清楚编码器应该是什么,这就是我传递ImageFormat 的原因。
是ImageFormat.Icon 没有任何编码器,还是我做错了什么?
【问题讨论】:
-
@abatishchev:British spell programme 就是这样:p