0

我希望使用 VB.NET 代码使位图图像 (.bmp) 透明。请帮助我。

4

3 回答 3

1

对比 2012

Dim watermark_bm2 As Bitmap = 'someimage(来自文件或全局资源)

watermark_bm2.MakeTransparent()

于 2013-06-03T16:41:05.123 回答
1

我发现关键是使用imageAttributes类。基本上将颜色键设置为您用来表示透明区域的颜色,并使用drawImage接受imageAttribute参数的调用之一...

Imports System.Drawing.Imaging

' and in a sub somewhere:

Private mImageAttributes As New ImageAttributes
mImageAttributes.SetColorKey(Color.FromArgb(0, 220, 20, 255), 
Color.FromArgb(0, 220, 20, 255))

Dim imageRectangle As New Rectangle(pX, pY, pBitmap.Width, pBitmap.Height)
e.Graphics.DrawImage(pBitmap, imageRectangle, 0, 0, pBitmap.Width, pBitmap.Height,
GraphicsUnit.Pixel, mImageAttributes)
于 2009-04-08T03:26:12.427 回答
0

这篇 msdn 文章提供了有关如何执行此操作的完整详细信息

这是另一篇文章,但代码示例在 c# 中

于 2009-04-07T06:09:27.317 回答