Reputation: 113
I am trying to write metadata to a png file using BitmapEncoder.
stream = co_await storageFile.OpenAsync(WS::FileAccessMode::ReadWrite);
decoder = co_await Windows::Graphics::Imaging::BitmapDecoder::CreateAsync(stream);
encoder = co_await Windows::Graphics::Imaging::BitmapEncoder::CreateForTranscoding(stream, decoder);
auto propertySet = winrt::Windows::Graphics::Imaging::BitmapPropertySet();
auto ratingValue = winrt::box_value(L"10");
auto value = winrt::Windows::Graphics::Imaging::BitmapTypedValue(ratingValue, winrt::Windows::Foundation::PropertyType::String);
propertySet.Insert(L"/tEXt/{str=Rating}", value);
co_await encoder.BitmapProperties().SetPropertiesAsync(propertySet);
co_await encoder.FlushAsync();
Upvotes: 1
Views: 109