|
-
Jun 14th, 2000, 06:27 AM
#8
Thread Starter
Addicted Member
****
ok Megatron, i'v done it,,but i have a problem, IT IS VERY SLOW, any way here is the code,,,see it and tell me why is it that slow please.
in a form, add two pictureboxes and a button,and this code:
[code]
Private Declare Function SetPixelV Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Byte
Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long) As Long
Private Sub Command1_Click()
For iWidth = 0 To (Picture1.Width / Screen.TwipsPerPixelX)
For iLength = 0 To (Picture1.Height / Screen.TwipsPerPixelY)
getpix = GetPixel(Picture1.hDC, iWidth, iLength)
getpic = Hex(getpix)
Hex1 = Mid(getpic, 1, 2)
Hex2 = Mid(getpic, 3, 2)
Hex3 = Mid(getpic, 5, 2)
RR = Hex2Dec(Hex3)
GG = Hex2Dec(Hex2)
BB = Hex2Dec(Hex1)
If RR < 256 And RR >= 0 Then RR = RR + 50
If GG < 256 And GG >= 0 Then GG = GG + 50
If BB < 256 And BB >= 0 Then BB = BB + 50
Picture2.BackColor = RGB(RR, GG, BB)
Fc = Picture2.BackColor
setPic = SetPixelV(Picture1.hDC, iWidth, iLength, Fc)
If iWidth Mod 20 = 0 Then Picture1.Refresh
Next iLength
Next iWidth
Picture1.Refresh
End Sub
Public Function Hex2Dec(ByVal sHex As String) As Long
Dim i As Integer
Dim nDec As Long
Const HexChar As String = "0123456789ABCDEF"
For i = Len(sHex) To 1 Step -1
nDec = nDec + (InStr(1, HexChar, Mid(sHex, i, 1)) - 1) * 16 ^ (Len(sHex) - i)
Next i
Hex2Dec = CStr(nDec)
End Function
[\code]
Thanx,,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|