see these 'for' loop:
Public Function SetTransparentColor(color As Long)
Dim X As Integer
Dim Y As Integer
Dim c As Long
Dim h As Long
Dim w As Long
Dim temp As BGRAQUAD ' substitua BGRColor pelo tipo de dado correto usado em bDibBGRA
h = Height - 1
w = Width - 1
For c = 0 To h * w ' movendo as operações fora do loop for
X = c Mod (w + 1)
Y = Int(c / (w + 1))
temp = bDibBGRA(c)
' modificando apenas a propriedade necessária
If (RGB(temp.B, temp.G, temp.R) = color) Then
temp.B = 255
bDibBGRA(c) = temp
End If
Next c
End Function
even i comment all the code, inside the 'for', i lose more than 50% of performance\optimization :(
in these case the image is 330X330.