开发者

Image GDI+ Error c#

First sorry for the english. I'm having an strange problem when I'm trying to save a bitmap ("Generic GDI+ error") from a picturebox in my win app, I know that this problem occurs when trying to save to a directory that 开发者_Python百科has no permission, but in this case I'm trying to save it to a memoryStream.

using (MemoryStream fotoStream = new MemoryStream())
{
    Bitmap imagen = picture1.Image as Bitmap;
    imagen.Save(fotoStream, imagen.RawFormat); //Error here
    byte[] array = fotoStream.ToArray();
    fotoStream.Close();
}

Any light on this?


Can you save the image in any other format, or by calling the Save overload that doesn't specify a format?

Have you checked the dimensions of the image to ensure that both width and height are non-zero?


How are you saving it to the database? You might want to create a test program that compares what you sent to the database and what you get back to make sure that they are the same.

Can you give us the full stack trace of the exception? imagen can't be null in this case or the exception would be a null exception when trying to access .RawFormat.

What does imagen look like in the debugger?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜