0
我使用automapper lib中的例外圖像轉換爲byte []和byte []到圖像中的模型爲什麼扔類型「System.ArgumentException」
m.CreateMap<Image, byte[]>().ConvertUsing<ImageToByteResolver>();
m.CreateMap<byte[], Image>().ConvertUsing<ByteToImageResolver>();
當我取automapper轉換字節數據[]數據圖像,但在轉換數據
public class ByteToImageResolver : ITypeConverter<byte[],Image>
{
public Image Convert(byte[] source, Image destination, ResolutionContext context)
{
using (var memStream = new System.IO.MemoryStream(source))
{
using (var bitmap = Bitmap.FromStream(memStream))
{
return (Image)bitmap;
}
}
}
}
發生錯誤編輯
這裏的錯誤,當我獲取數據
但轉換byte[]
到image
時,不會發生錯誤
請張貼整個異常堆棧跟蹤和異常消息。 – Dai
我懷疑你在'Bitmap.FromStream'構造函數中得到了一個GDI參數異常,這意味着你沒有正確加載圖像文件,或者你正在加載一個GDI不支持的圖像類型。 – Dai
當你的方法返回時,最內層的''''會退出,你正在處理'bitmap' – pinkfloydx33