SoftwareBitmap compared to BitmapImage

时间:2017-08-04 12:01:29

标签: c# uwp bitmapimage

So I'm creating a UWP app which includes an InkCanvas, as such, I want to store the contents as a variable so that I can show a preview of the canvas in the menu.

My question is, what is the best bitmap to use, as there appear to be a number of options.

The SoftwareBitmap is included in Windows.Graphics.Imaging, whereas the BitmapImage is part of Windows.UI.XAML.Media.Imaging, both of which are available in a UWP app.

Can the UWP Image class for displaying images use either of these formats?

Which is most appropriate in my case?

1 个答案:

答案 0 :(得分:1)

所以做了很多实验,似乎与Image的{​​{1}}控件一起使用,Windows.UI.XAML.Controls工作得相当好。

如果SoftwareBitmapSoftwareBitmapSourceImage.Source(或SoftwareBitmap),则BitmapPixelFormat.Bgra8可以分配到BitmapAlphaMode.Premultiplied。来自SoftwareBitmapSource页面上的备注部分:

  

XAML应用中显示的SoftwareBitmap必须采用BGRA像素格式,并预先乘以alpha值

一切正常,现在可以缩小位图,因为BitmapAlphaMode.NoneInkCanvas之间的大小差异会使缩略图/预览看起来很差。