简体   繁体   English

如何使用 C# 在 canvas 上的 WPF 中绘制透明 PNG

[英]How do I draw a transparent PNG in WPF on a canvas using C#

This doesn't seem to be answered.这似乎没有答案。 I have a png ("Blue Arrow.png") which has a white background.我有一个白色背景的 png(“Blue Arrow.png”)。 I want to draw it on a canvas at location X,Y with rotation R with the white background being transparent.我想在 X,Y 位置的 canvas 上绘制它,旋转 R,白色背景是透明的。

Can somebody please point me in the right direction?有人可以指出我正确的方向吗? The Googles they're not turning up anything.谷歌他们没有发现任何东西。

There is no direct way in WPF to remove the background of a PNG and make it transparent. WPF 中没有直接的方法来删除 PNG 的背景并使其透明。 It would be much easier to start with a PNG that has a transparent background.从具有透明背景的 PNG 开始会容易得多。

Even if you find an external library that will do color keying/replacement, the quality won't be as good as starting with a proper PNG.即使您找到一个可以进行颜色键控/替换的外部库,质量也不会像从正确的 PNG 开始那样好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM