有没有人知道为Windows UWP应用程序分层PNG图像的解决方案? 在保持透明度的同时?
(此解决方案在UWP应用程序中不起作用)
Merge two png images with transparency and retain transparency
最终目标是将PNG文件合并到Image对象,以便将其添加到Grid控件。
答案 0 :(得分:2)
一种可能的解决方案是在WriteableBitmapEx中使用Blit
方法。此方法将像素从WriteableBitmap源复制(blits)到目标WriteableBitmap(this),以下是一个简单的示例。
var writeableBmp = new WriteableBitmap(1, 1);
var image1 = await writeableBmp.FromContent(new Uri("ms-appx:///Assets/image1.png"));
var image2 = await writeableBmp.FromContent(new Uri("ms-appx:///Assets/image2.png"));
image1.Blit(new Rect(0, 0, image1.PixelWidth, image1.PixelHeight), image2, new Rect(0, 0, image2.PixelWidth, image2.PixelHeight));
//BlendedImage is a Image control in XAML
BlendedImage.Source = image1;
答案 1 :(得分:0)
我认为你可以在Xaml中使用Grid中的两个图像控件,并且两者都在viewModel中绑定透明度。但是我看到了链接,我也无法使用它。可能MS改变API。我也很有意思
答案 2 :(得分:0)
Lumia Imaging SDK正在做你想做的事。它可以将2个以上的图像混合在一起。
您可以找到示例代码here