Thursday, August 21, 2008

VB.Net Usefull Code Snippets

From: http://www.dreamincode.net/code/snippet870.htm

Change bitmaps certain color transparency


  1. 'Written by Margus Martsepp AKA m2s87
  2. Private Function v2bista(ByRef OnPict As System.Drawing.Bitmap, _
  3. ByVal xColor As System.Drawing.Color, _
  4. ByVal How_Tr As Integer) As Boolean
  5. Dim x%, y%, R%, G%, B%
  6. v2bista = True
  7. With OnPict
  8. For x = 1 To .Width - 1
  9. For y = 1 To .Height - 1
  10. R = .GetPixel(x, y).R
  11. G = .GetPixel(x, y).G
  12. B = .GetPixel(x, y).B
  13. If xColor.R = R And xColor.G = G And xColor.B = B Then
  14. .SetPixel(x, y, System.Drawing.Color.FromArgb(How_Tr, R, G, B))
  15. End If
  16. Next
  17. Next
  18. End With
  19. End Function

No comments: