gpt4 book ai didi

c# - 在 c# wpf 中从 Memorystream 获取图像源

转载 作者:IT王子 更新时间:2023-10-29 04:41:29 24 4
gpt4 key购买 nike

如何使用 C# 在 WPF 中从 MemoryStream 获取 ImageSource?或者将 MemoryStream 转换为 ImageSource 以在 wpf 中将其显示为图像?

最佳答案

using (MemoryStream memoryStream = ...)
{
var imageSource = new BitmapImage();
imageSource.BeginInit();
imageSource.StreamSource = memoryStream;
imageSource.EndInit();

// Assign the Source property of your image
image.Source = imageSource;
}

关于c# - 在 c# wpf 中从 Memorystream 获取图像源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6588974/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com