VB.NET:
Public Function transpicture(ByVal pic As PictureBox)
Dim x As Integer, y As Integer
Dim bmp As New Bitmap(pic.Image)
Dim gp As New System.Drawing.Drawing2D.GraphicsPath
Dim mask As Color = bmp.GetPixel(0, 0)
For x = 0 To bmp.Width - 1
For y = 0 To bmp.Height - 1
If Not bmp.GetPixel(x, y).Equals(mask) Then
gp.AddRectangle(New Rectangle(x, y, 1, 1))
End If
Next
Next
pic.Region = New System.Drawing.Region(gp)
bmp.Dispose()
End Function
Is there a way to speed up this code at all, maybe a diffeent way of doing it. I am placing the picturebox onto a moving map so I cant use the transparent option on a picturebox as it makes the whole picture disappear, this function does work, but it takes about 4 sec's to do the picture.
thanks
Steve