Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
MACRO mGetRed (Rgbvalue) = Rgbvalue AND &h0FF
MACRO mGetGreen (rgbvalue) = (Rgbvalue AND &h0FF00) \ &h100
MACRO mGetBlue (rgbvalue) = (rgbvalue AND &h0FF0000) \ &h100
Global hDlg as Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, 100,"Push", 50,10,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If Cb.Msg = %WM_Command And Cb.Ctl = 100 Then
Local i,R,G,B,iStart, iEnd, rgbColor As Long
'Win32api.inc
iStart = GetTickCount
rgbColor = %rgb_LightBlue
For i = 1 To 10000000
R = GetRValue(rgbColor)
G = GetGValue(rgbColor)
B = GetBValue(rgbColor)
Next i
iEnd = GetTickCount
? "win32api.inc: " + Format$((iEnd - iStart)/1000,3) & " seconds"
'Jordi
iStart = GetTickCount
rgbColor = %rgb_LightBlue
For i = 1 To 10000000
R = rgbcolor And &h000000FF 'Red
Shift Right rgbColor, 8
G = rgbcolor And &h000000FF 'Green
Shift Right rgbColor, 8
B = rgbcolor And &h000000FF 'Blue
Next i
iEnd = GetTickCount
? "jordi: " + Format$((iEnd - iStart)/1000,3) & " seconds"
'MCM
iStart = GetTickCount
rgbColor = %rgb_LightBlue
For i = 1 To 10000000
R = mGetRed(rgbColor)
G = mGetGreen(rgbColor)
B = mGetBlue(rgbColor)
Next i
iEnd = GetTickCount
? "mcm: " + Format$((iEnd - iStart)/1000,3) & " seconds"
End If
End Function
'gbs_00867
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm