Hello Everyone I am new to wp7.
My issue is I'm saving bitmap image 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 can I save a bitmap image with a transparent background ?
JPEG files do not allow transparency. GIF and PNG formats do.
So what you may do is save files into PNG or GIF formats. Take a look at the ImageTools library on Codeplex . Using this library it is quite easy to save your bitmap data into a format that keeps the transparency information.
The post is a bit old, 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 have posted the interesting bit of code here, but unfortunately Skydrive is blocked by my proxy :-)
You may be interested in checking out the differences between the three formats I mentioned above in a dated but still valid article on SitePoint: http://www.sitepoint.com/gif-png-jpg-which-one-to-use/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.