Search code examples
c#arraysimage-processingtransparency

Converting Bytes to a transparent image


I already faced the issue with inserting a transparent image to sql by MemoryStream and I fixed it with File.ReadAllBytes(filePath), MemoryStream doesn't make the transparent areas right and now for getting that image right I don't know what should I do. I searched posts from stack overflow and also other websites, there was posts about inserting a transparent image to sql but didn't noticed any about this

 using (Image image = Image.FromStream(new MemoryStream(bitmap)))
 {
     image.Save(Address, ImageFormat.Jpeg);
 }

Does anyone knows how can I convert bytes to a transparent image right tnx


Solution

  • You are saving your image to a JPEG-file. JPEG-images do not support transparancy. You could use PNG- or GIF-images. They both support transparancy.