3

我想定期更新 Flip Tile Back Image,以便添加ScheduledAgentProject 并尝试将图像保存在内部的固定路径中isolated Share Folder。但是当我设置BitmapImageSource from时出现内存不足异常Image Stream

这是代码

    using (var isoFile = IsolatedStorageFile.GetUserStoreForApplication())
    {
        const string filePath = @"Shared\ShellContent\FlipBackImage.jpg";
        var filename = "Image.png";
        var stream = !isoFile.FileExists(filename) ? null : isoFile.OpenFile(filename, FileMode.Open, FileAccess.Read);
        if (stream != null)
        {
            if (isoFile.FileExists(filePath))
            {
                isoFile.DeleteFile(filePath);
            }
            Debug.WriteLine("currentMemory"+DeviceStatus.ApplicationCurrentMemoryUsage);
            var bi = new BitmapImage();
            bi.CreateOptions = BitmapCreateOptions.None;
            bi.SetSource(stream); //out of memory exception getting here
            var wbm=new WriteableBitmap(bi);
            using (var streamFront = isoFile.OpenFile(filePath, FileMode.Create))
            {
                wbm.SaveJpeg(streamFront, 691, 336, 0, 80);
            }
            Deployment.Current.Dispatcher.BeginInvoke(() => Utils.DisposeImage(wbm));
        }

每次尝试设置一个甚至它的大小Image时都会出现异常。 如何处理?Resolution 1500x110029 kb

4

1 回答 1

0

iso.Close();

一旦图像流读取完成就写这个

于 2013-12-20T10:37:54.990 回答