开发者

how can I set the metadata of an image using WPF?

开发者 https://www.devze.com 2023-01-12 07:12 出处:网络
WPF has an Image开发者_StackOverflow社区Source which has a BitmapMetadata. However, the Metadata property is read only an the BitmapMetadata is frozen.

WPF has an Image开发者_StackOverflow社区Source which has a BitmapMetadata.

However, the Metadata property is read only an the BitmapMetadata is frozen.

So I can I modify the metadata of an image?


Unfortunately the WPF imaging API doesn't allow you to modify the image metadata... However, you can still do it with GDI+ (System.Drawing)


Found the answer:

var frame = ...;

BitmapMetadata newMetadata = ...;

var newFrame = BitmapFrame.Create(frame, frame.Thumbnail, newMetadata, frame.ColorContexts);

var encoder = new JpegBitmapEncoder();

encoder.Frames.Add(newFrame);

0

精彩评论

暂无评论...
验证码 换一张
取 消