c# - WritableBitmap - Save custom live tile as Transparent PNG -
c# - WritableBitmap - Save custom live tile as Transparent PNG -
having bit of problem creating writablebitmap , saving beingness writablebitmap seems back upwards jpeg. obviously, quite inconvenience , don't know it. how can go making writablebitmap save png file that supports windows phone 8.1 transparent tiles w/ background?
note i'm targeting 8.0.
my code:
private static void createbitmap(int width, int height) { writeablebitmap b = new writeablebitmap(width, height); var canvas = new grid(); canvas.width = b.pixelwidth; canvas.height = b.pixelheight; var background = new canvas(); background.height = b.pixelheight; background.width = b.pixelwidth; // removed area of code contains design live tile. b.render(background, null); b.render(canvas, null); b.invalidate(); //draw bitmap using (isolatedstoragefile isf = isolatedstoragefile.getuserstoreforapplication()) { using (isolatedstoragefilestream imagestream = new isolatedstoragefilestream("/shared/shellcontent/" + imagename + ".jpeg", system.io.filemode.create, isf)) { b.savejpeg(imagestream, b.pixelwidth, b.pixelheight, 0, 100); } } }
there toolkit called cimbalino wp has extension method saving pngs using writeablebitmap. cimbalino available on nuget, savepng extension method need background components.
here's code sample on how utilize it:
using (isolatedstoragefile isf = isolatedstoragefile.getuserstoreforapplication()) { using (isolatedstoragefilestream imagestream = new isolatedstoragefilestream("/shared/shellcontent/" + imagename + ".png", system.io.filemode.create, isf)) { cimbalino.phone.toolkit.extensions.writeablebitmapextensions.savepng(b, imagestream); } }
c# image windows-phone-8 bitmap
Comments
Post a Comment