简体   繁体   English

将PNG转换为JPG Windows Phone

[英]Convert PNG to JPG Windows Phone

i have a PNG file and i would convert into JPG The PNG is a large size(high resolution) (for example 30/40MB) 我有一个PNG文件,我将转换为JPG PNG是大尺寸(高分辨率)(例如30 / 40MB)

if i use this code receive a memory leak 如果我使用此代码会收到内存泄漏

using (var fileStream = myIsolatedStorage.OpenFile("1.png",FileMode.Open,FileAccess.Read))
{
    WriteableBitmap wb = PictureDecoder.DecodeJpeg(fileStream);
}

How to? 如何? Thanks 谢谢

Your code cannot work since you loaded a png file, but the method beneath accepts jpeg stream. 由于您加载了png文件,因此您的代码无法正常工作,但是下面的方法接受jpeg流。 You can do the following> 您可以执行以下操作>

  1. Open the png file with OpenFile 使用OpenFile打开png文件
  2. Load the file into a BitmapImage 将文件加载到BitmapImage
  3. Create a WriteableBitmap from that BitmapImage 从该BitmapImage创建一个WriteableBitmap
  4. Save the created WriteableBitmap as a jpeg file using the SaveJpeg extension method. 使用SaveJpeg扩展方法将创建的WriteableBitmap保存为jpeg文件。

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

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