So I'm trying to save a user's control to use a png as a tile. Code which I am using
category class = new category (); Sq.Measure (new size (336,336)); Sq.rrange (new rectangle (0,0,336,336)); RenderExtensions.SaveToFile (class);
and RenderExtension class looks like this
public static class RenderExtensions {SaveToFile (this UIElement visualTreeElement) {WriteableBitmap WB = new WriteableBitmap bool public static ( 336, 336); Wb.Render (visual perimeter, blank); Wb.Invalidate (); Return wb.SaveToFile (); } Public Static Bull SaveToFile (this writeable bitmap rendertrainbillmate) {try {string fname = "shared / ShellContent / SquareTile.png"; // StorageFile liveTileImageFile = localFolder.CreateFile ( "/ share / ShellContent / SquareTile.png", CreationCollisionOption.ReplaceExisting); Extended image ei = new extended image (); Byte [] results = new byte [rendertigitbitmap. Pixel Length * size]; Buffer.blackcopy (rendererbitmap pixel, 0, result, 0, result. Length); Ei.SetPixels (336,336, results); If (Ei! = Null) {IsolatedStorageFile isf = isolated storage file.NetusourceStoreFirection (); (Using Isf) (if (! Isf.DirectoryExists ( "share")) {isf.CreateDirectory ( "Share");} If (! Isf.DirectoryExists ( "Shared / ShellContent")) {isf.CreateDirectory ( " Shared / ShellContent ");} if (isf.FileExists (fname)) {isf.DeleteFile (fname);} using (var stream = new IsolatedStorageFileStream (fname, System.IO.FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare. ReadWrite, ISF)) {ei.WriteToStream (stream, fname); stream.Close ();}}} true;} catch (exception ex) {return false;}}}
Now the tile looks like this (note background color has some transparency)
And if I'm one in a grid To add Mr. UserControl, it really https://i.stack.imgur.com/piLT0 the
Here is the original image that is showing this user control
You can see how Lal has made a blue color, although the image is not transparent. Why is this happening?
Update: I also tried a different image, in which only three colors are red, blue and yellow, only red and blue are changing.
OK I have managed swap using red and blue, this function
Private Static Byte [] Convert Array (int [] Array) {Byte [] New Array = New Byte [Array. Height * 4]; For (int i = 0; i and lt; array langith; i ++) {newer [i * 4] = (byte) (array [i]> gt;> 16); NewRay [i * 4 + 1] = (byte) (array [i]> gt; & gt; 8); NewRay [i * 4 + 2] = (byte) (array [i]); Newer than [i * 4 + 3] = (byte) (array [i]> gt; 24); } Return Nuere; }
Now I am not using
Buffer.BlockCopy (renderTargetBitmap.Pixels, 0, results, 0, result.Length);
No comments:
Post a Comment