简体   繁体   English

如何在Shared / ShellContent文件夹中为辅助Tile保存png文件

[英]How to save png file in Shared/ShellContent folder for secondary Tile

I have tried searching this but i only end up with saving as jpg which doesn't contains transparency. 我尝试搜索此内容,但最终只保存为不包含透明度的jpg。

using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (myIsolatedStorage.FileExists("Shared/ShellContent/logo.jpg"))
                {
                    return;
                }

                IsolatedStorageFileStream fileStream1 = myIsolatedStorage.CreateFile("Shared/ShellContent/logo.jpg");

                Uri uri = new Uri("home.png", UriKind.Relative);
                StreamResourceInfo sri = null;
                sri = Application.GetResourceStream(uri);
                BitmapImage bitmapImage = new BitmapImage();
                bitmapImage.SetSource(sri.Stream);
                WriteableBitmap wb = new WriteableBitmap(bitmapImage);

                Extensions.SaveJpeg(wb, fileStream1, wb.PixelWidth, wb.PixelHeight, 0, 95);    

                fileStream1.Close();
            }

How can i save image as it is, without encoding it jpg format? 如何不按jpg编码格式保存图像?

I did it by following this http://toolstack.com/libraries/pngwriter 我是通过遵循此http://toolstack.com/libraries/pngwriter实现的

Final Code 最终密码

using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (myIsolatedStorage.FileExists("Shared/ShellContent/logo.png"))
                {
                    return;
                }

                IsolatedStorageFileStream fileStream1 = myIsolatedStorage.CreateFile("Shared/ShellContent/logo.png");

                Uri uri = new Uri("home.png", UriKind.Relative);
                StreamResourceInfo sri = null;
                sri = Application.GetResourceStream(uri);
                BitmapImage bitmapImage = new BitmapImage();
                bitmapImage.SetSource(sri.Stream);
                WriteableBitmap wb = new WriteableBitmap(bitmapImage);

                wb.WritePNG( fileStream1 as System.IO.Stream);

                //wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);

                fileStream1.Close();
            }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM