以编程方式更改图像源
change image source programmatically
我不知道如何将映像从磁盘动态加载到Xaml映像控件。
<Image x:Name="imgLogo" ....../>
然后在我的c++类中,我找不到任何可以使用的例子。大多数都在c#中。一个烦恼是,我一直在使用System.Windows.Media::ImageSource,但这不在我的框架中。
有人能给我举个例子吗。我来自iOS世界,不习惯MS及其框架。
谢谢,
试试这个,它在C#中,但应该很容易转换:
using Windows.UI.Xaml.Media.Imaging;
<Image Margin="5" Source="{Binding BMImage}" Height="100"/>
bmImage = new BitmapImage();
bmImage.UriSource = new Uri(new Uri(
*your file path*,
*your image name*);
BitmapImage bmImage;
public BitmapImage BMImage
{
get
{
return bmImage;
}
}
取自这里(我的博客)。
要更改图像,只需更改bmImage
的值并调用NotifyPropertyChanged(()=>BMImage);
(假设您有该设置)
有关如何使用图像的Microsoft示例,请参见此处。
请参阅此处以获取Windows.UI.Xaml.Media.Imaging
命名空间。
相关文章:
- 以跨平台的方式将图像源路径从C++发送到 QML
- 哪种方式更快?究竟发生了什么,我们没有看到什么?
- clang++ 是否以更轻松的方式处理系统标头?
- SDL GPU 为什么将两个图像分成两个单独的循环更快?
- 在 Visual C++ 中以编程方式更改按钮的背景图像
- 更快地将卤化物图像转换为 opencv 垫?
- 如何以更有效的方式检查一个数字是否是素数?
- 以更优雅的方式获得C++的当年
- 尝试使用 Qt 库中的 QPixmap 将图像拆分为多个块。关于他的复制方法的工作方式,我有什么不明白的吗?
- 更快的图像镜像算法
- 在 OpenGL 中渲染对象的哪种方式更有效
- 在哪种方式搜索容器中的元素的方式更有效
- MPI BMP 图像比较更高效
- 哪种方式更快
- 哪种方式更好地获得64位整数中较低的32位
- 哪种方式更适合定义类型特征或行为
- 哪种方式更适合阵列访问
- 当使用getline时,哪种方式更好
- c++ ||添加两个矩阵的方式更容易输出
- 哪种沟通方式更有效