Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 如何将隔离存储映像作为流获取?_C# 4.0_Windows 8_Windows Phone 8_Isolatedstorage - Fatal编程技术网

C# 4.0 如何将隔离存储映像作为流获取?

C# 4.0 如何将隔离存储映像作为流获取?,c#-4.0,windows-8,windows-phone-8,isolatedstorage,C# 4.0,Windows 8,Windows Phone 8,Isolatedstorage,我有一个非常罕见的问题。首先让我告诉你,我想建立一个关于图像的WP8应用程序。我在项目解决方案中存储了一些图像,并将这些图像用于应用程序,效果良好。 我正在用一个 public Stream ImageStream { get { return this.imageStream; } set { this.imageStream = value;

我有一个非常罕见的问题。首先让我告诉你,我想建立一个关于图像的WP8应用程序。我在项目解决方案中存储了一些图像,并将这些图像用于应用程序,效果良好。 我正在用一个

public Stream ImageStream
    {
        get
        {
            return this.imageStream;
        }

        set
        { 
            this.imageStream = value;
        }  
}

现在对于项目解决方案图像,我这样调用这个图像流

StreamResourceInfo imageRes = Application.GetResourceStream(new Uri("WindowsPhone;component/Images/Image1.jpg", UriKind.Relative));
    this.ImageStream = imageRes.Stream;
现在,如果我尝试使用媒体库中的任何图像,问题就开始了。我可以将文件存储到独立的存储器中,并可以从它们的存储库访问该文件。我正在做的是

using (IsolatedStorageFile Iso = IsolatedStorageFile.GetUserStoreForApplication())
 {
     using (var stream = new IsolatedStorageFileStream(strFileName, FileMode.Open, FileAccess.Read, Iso))
     { 
         IsolatedStorageFileStream fileStream = Iso.OpenFile(strFileName, FileMode.Open, FileAccess.Read);

                    data = new byte[stream.Length];

                    // Read the entire file and then close it
                    stream.Read(data, 0, data.Length);
                    stream.Close();                     
                }
            }
            MemoryStream ms = new MemoryStream(data);
            BitmapImage bi = new BitmapImage();

            // Set bitmap source to memory stream
            bi.SetSource(ms);
然而,我可以使用图像文件,可以显示,但你可以看到它是一个位图图像,因为它是在隔离存储我不能使用

StreamResourceInfo imageRes ...
this.ImageStream = ...
有什么帮助吗?我如何使用这个。ImageSteam属性?任何其他想法都将受到欢迎。我实际上是WP8编程的初学者

或者让我问你一个简单的问题,我如何将隔离存储中的图像读取到
StreamResourceInfo


如果我能做到,我的问题就解决了。请帮助我。

为什么要执行流复制

试试像这样的东西

BitmapImage bi = new BitmapImage();
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
    using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile("logo.jpg", FileMode.Open, FileAccess.Read))
    {
        bi.SetSource(fileStream);
        this.img.Height = bi.PixelHeight;
        this.img.Width = bi.PixelWidth;
    }
}
this.img.Source = bi;

为什么要执行流复制

试试像这样的东西

BitmapImage bi = new BitmapImage();
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
    using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile("logo.jpg", FileMode.Open, FileAccess.Read))
    {
        bi.SetSource(fileStream);
        this.img.Height = bi.PixelHeight;
        this.img.Width = bi.PixelWidth;
    }
}
this.img.Source = bi;
*将映像保存到独立存储:*

快乐编码…

*将图像保存到独立存储:*


快乐编码…

感谢您的回答,但ImageStream Prpoerty实际上在setter中做了更多的工作,它不仅仅是设置;但这是裁剪我的形象,并返回,通过得到;所以我需要称之为ImageStream。我已经完成了你说的。谢谢你的回答,但是ImageStream Prpoerty实际上在setter中做的更多,它不仅仅是set;但这是裁剪我的形象,并返回,通过得到;所以我需要称之为ImageStream。我已经完成了你说的。谢谢你的回答,我已经浏览了这个网站,我可以在我的游戏容器中显示图像,但它只是一个原始图像,而不是我想要显示的作物图像。所以裁剪是由ImageStream Prpoerty完成的,这就是为什么我需要调用它。在我得到图片后,你发布的是Windowsphonegeek.com,我在之前的评论中告诉你,我已经浏览了这个网站,没有什么帮助。我的问题是如何将孤立的图像文件作为流?到目前为止没有答案。我知道如何将文件保存在独立存储中,以及如何检索它们。问题仍然悬而未决,但目前我使用了不同的方法来完成代码工作。谢谢你的回答,我已经浏览了这个网站,我可以在我的游戏容器中显示图像,但它只是一个原始图像,而不是我想要显示的作物图像。所以裁剪是由ImageStream Prpoerty完成的,这就是为什么我需要调用它。在我得到图片后,你发布的是Windowsphonegeek.com,我在之前的评论中告诉你,我已经浏览了这个网站,没有什么帮助。我的问题是如何将孤立的图像文件作为流?到目前为止没有答案。我知道如何将文件保存在独立存储中,以及如何检索它们。这个问题仍然悬而未决,但是目前我使用了一种不同的方法来完成代码的工作。