3
Answers

A generic error occurred in GDI+ when savin image

Rahul Singi

Rahul Singi

12y
7.8k
1
Hi to all

when i am converting image to byte array then i got the error : "A generic error occurred in GDI+."

My code is as follows :

  using (MemoryStream stream = new MemoryStream())
  {
  sPath.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
  data = stream.ToArray();
  }
  return data;

and i am also trying this code :

  ImageConverter converter = new ImageConverter();
  return (byte[])converter.ConvertTo(sPath, typeof(byte[]));

but i got the same error.

Answers (3)