显示文件中的图像 [英] Display images from file
问题描述
您好,运行IoT的Raspbberry Pi3上的
10.0.17763.379我正面临这个问题:
Hello,
on a Raspbberry Pi3 running IoT 10.0.17763.379 I am facing this issue:
XAML:
< Image x:Name =" image2"的HorizontalAlignment = QUOT;左"高度= QUOT; 140"余量= QUOT; 175,287,0,0" VerticalAlignment = QUOT;陀螺"宽度= QUOT; 140" RenderTransformOrigin = QUOT; -2.535,0.75"源= QUOT; /Assets/unknown.png"
Stretch =" None" />
$
这很好用,它显示我在Assets项目中包含的图片,很棒。
但是当我想在运行期间更改图像时,我总是会显示一张空白图片。我浏览了很多网站,并了解这是改变图像sourec URI的预期方法:
<Image x:Name="image2" HorizontalAlignment="Left" Height="140" Margin="175,287,0,0" VerticalAlignment="Top" Width="140" RenderTransformOrigin="-2.535,0.75" Source="/Assets/unknown.png"
Stretch="None"/>
This works fine, it displays the picture that I included in the project under Assets, great.
However when I want to change the image during runtime I always get a blank picture displayed. I browsed many sites and understand that this is the expected way to change the image sourec URI:
BitmapImage src = new BitmapImage();
src.UriSource =新的Uri("C:\\ pics \\Pic3.png",UriKind.Absolute);
image2.Source = src;
BitmapImage src = new BitmapImage();
src.UriSource = new Uri("C:\\pics\\Pic3.png", UriKind.Absolute);
image2.Source = src;
我尝试了很多方法,结果总是一样的。显示存储在我硬盘上的图片永远无法正常工作,当我分配任何资产图片时,它始终有效。
I tried many ways, the result is ALWAYS the same. Showing a picture stored on my HDD never works, when I assign any picture of my assets it always works.
谁可以建议我必须做什么才能在运行时图片中动态显示磁盘?我将收集许多图片,并且不能将它们全部包含在我项目的资产中。
Who can advise what I have to do in order to display dynamically during runtime pictures from the disk? I will have a collection on many pictures and cannot include them all in the assets of my project.
我使用VS2017版本15.9.10
I am using VS2017 version 15.9.10
谢谢
推荐答案
Hello Thomas Schattat,
Hello Thomas Schattat,
通用Windows平台(UWP)应用可以访问某些默认情况下,文件系统位置禁止访问您的代码中使用的文件夹 C:\\ pics 。 Windows IoT Core上的应用程序可以通过声明功能访问其他位置。
请参阅有关 Windows IoT核心上的
文件访问权限。
Universal Windows Platform (UWP) apps can access certain file system locations by default, the folder C:\\pics which used in your code is prohibited to access. Apps on Windows IoT Core can access additional locations by declaring capabilities. Please refer to a topic about File Access on Windows IoT Core.
最好的问候,
迈克尔
这篇关于显示文件中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!