什么是相当于VB6.0' c#中的MaskColor属性

本文关键字:中的 MaskColor 属性 相当于 VB6 什么 | 更新日期: 2023-09-27 18:06:05

在vb6.0中使用MaskColor属性去除Image的背景色。我如何在c#中做同样的事情?

什么是相当于VB6.0' c#中的MaskColor属性

您可以对位图图像使用MakeTransparent(Color Color)。例子:

//convert the red color in the image into transparent.
((Bitmap)BackgroundImage).MakeTransparent(Color.Red);

我不认为有任何直接的等同。

我已经使它工作在过去通过使用ColorMap类映射我的背景颜色到color . transparent。然后我创建一个ImageAttributes对象并调用SetRemapTable()函数并将我的ColorMap传递给它。然后通过将ImageAttributes传递给DrawImage方法来重新绘制图像。

编辑:

Jalal发布了一个更简单的纯色方法。我仔细查看了一下使用上述方法的代码,我将相同基本颜色的多个阴影映射到透明。