使图像的一部分透明 [英] Make part of an image transparent

查看:43
本文介绍了使图像的一部分透明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将图像放在按钮上,但我希望图像的一部分是透明的.我该怎么做?

I want to put an image on a button, but I want part of the image to be transparent. How do I do this?

推荐答案

试试 Image.OpacityMask 属性.你可以给它一个画笔,指定你想要透明的区域.

Try the Image.OpacityMask property. You can give it a brush that specifies the region you want to be transparent.

编辑:来自MSDN:

没有直接支持在 WPF 中对位图进行颜色键控.然而,这相当容易自行实施.德韦恩有在他的身上实现了一个 ColorKeyBitmap博客:http://blogs.msdn.com/dwayneneed/archive/2008/06/20/implementing-a-custom-bitmapsource.aspx我相信它链接到代码Codeplex 也是如此.你也可以只需阅读您的位图进入系统内存,迭代通过所有像素和设置他们自己的价值观,以及从中构建一个新的位图数组.

There is no direct support for color-keying a bitmap in WPF. However, it is fairly easy to implement on your own. Dwayne has implemented a ColorKeyBitmap on his blog: http://blogs.msdn.com/dwayneneed/archive/2008/06/20/implementing-a-custom-bitmapsource.aspx I believe it links to the code on Codeplex as well. You could also accomplish this simply by reading your bitmap into system memory, iterating through all the pixels and setting their values yourself, and constructing a new bitmap out of that array.

这篇关于使图像的一部分透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆