我想在C ++ / CX中从png数据的std :: string创建一个BitmapImage。这是我的代码。正在创建BitmapImage,但在与Xaml中的Image元素源绑定时,它不会显示。
void setImage(std::string imageDataStr, uint64_t len) {
auto stream = ref new InMemoryRandomAccessStream();
auto writer = ref new DataWriter(stream->GetOutputStreamAt(0));
Platform::Array<unsigned char>^ data = ref new Platform::Array<unsigned char>((unsigned char*)imageDataStr.data(), len);
writer->WriteBytes(data);
create_task(writer->StoreAsync()).then([=](unsigned bytesStored)
{
Image->SetSource(stream);
});
}
我做错了吗?
有什么建议吗?