Windows Phone 8 bitmap transparency

May 9, 2013 at 10:15 AM
I discovered an issue which has to do with the transparency of a bitmap.
Mapsui uses a SymbolStyle with a Bitmap object, which is in fact a stream:
var symbol = new SymbolStyle { Symbol = new Bitmap { Data = stream} };

In Windows Phone, you must convert a (writeable)bitmap into a stream. This can only be done by saving the bitmap as JPEG. Unfortenately, the transparency information is lost doing so.

When displaying the bitmap as UIElement on the canvas, everything is ok.
@Paul: is there a way around this issue? Any ideas?
May 9, 2013 at 2:12 PM
Take a look at ConverToBitmapStream over here:
Tell me if it solves your problem.
May 10, 2013 at 1:09 PM
Sorry, does not work. No transparency.
May 10, 2013 at 3:19 PM
How does your sample behave if you try regular Silverlight?
May 31, 2013 at 10:17 AM
Solution (thanks Paul):
1) add a PNG file to yout VS project. For example: I added a gps.png file in the /Images folder. The PNG has transparency, of course.
2) Set the property of the PNG to: "Embedded Resource" and "Do not copy".
3) Create a layer (in this example: pointLayer) and use the following code:
pointLayer.Styles.Clear(); //clear default style
var bitmapData = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Mapsui.Samples.WP8.Images.gps1.png");
var symbolStyle = new SymbolStyle { Symbol = new Bitmap { Data = bitmapData } };
4) now the PNG is displayed with transparency!