如何制作没有矩形边框的图形?

如何制作没有矩形边框的图形?比如桌面上的快捷图标。目的是画一个喇叭,在.net窗体上不显示原始喇叭位图的非喇叭部分,谢谢!
---------------------------------------------------------------

Dim Path As New GraphicsPath()
Dim g As Graphics = Me.CreateGraphics
Dim b As New Bitmap("G:\新建文件夹\icon_eek.gif")
Dim x, y, i As Long
Dim rect As Rectangle
'取得(1,1)位置的象素点是因为要把图片的背景边框去掉
Dim colorFirst As Color = b.GetPixel(1, 1)
For x = 0 To b.Width - 1
For y = 0 To b.Height - 1
If b.GetPixel(x, y).Equals(colorFirst) Then

Else
rect = New Rectangle(x, y, 1, 1)
Path.AddRectangle(rect)
End If
Next y
Next x
然后按照这个路径去画就可以了。
---------------------------------------------------------------

1楼老大,思路非常不错。
呵呵,只是GDI+已经提供了现成的方法了,只用一句就能实现您的思路了:

Dim b As New Bitmap("G:\新建文件夹\icon_eek.gif")
b.MakeTransparent(b.GetPixel(0, 0))

Published At
Categories with Web编程
Tagged with
comments powered by Disqus