How to save a bitmap with transparent background in wp7

Hello everyone. I am new to wp7.

My problem is that I save the bitmap, but the background of the image is not transparent. See my code below:

IsolatedStorageFileStream fileStream = myIsolatedStorage.CreateFile(fileName); var bitmap = new WriteableBitmap(500, 700); bitmap.Render(paint, null); bitmap.Invalidate(); WriteableBitmap wb = new WriteableBitmap(bitmap); wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85); fileStream.Close(); 

How to save a bitmap with a transparent background?

+4
source share
1 answer

JPEG files do not allow transparency. GIF and PNG format.

So, you can save files in PNG or GIF format. Take a look at the ImageTools library on Codeplex . Using this library, it’s quite simple to save bitmap data in a format that stores transparency information.

The post is a bit dated, but Jaime Rodriguez wrote an example using this library: http://blogs.msdn.com/b/jaimer/archive/2010/11/23/working-with-gif-images-in-windows-phone. aspx I would post an interesting bit of code here, but unfortunately Skydrive is blocked by my proxy :-)

You may be interested in checking the differences between the three formats mentioned above in a dated but still valid SitePoint article: http://www.sitepoint.com/gif-png-jpg-which-one-to-use/

+3
source

All Articles