Date: 02-16-2022
Return to Index
'Compilable Example: (Jose Includes)
created by gbSnippets
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
%ID_VisibleA = 500
%ID_VisibleB = 600
%ID_Timer = 700
Global hDlg, hbmpADC, hsourceA, hsourceAdc as dword
Global hbmpBDC, hsourceB, hsourceBdc as dword
Function PBMain() As Long
Dialog New Pixels, 0, "Rotate",200,150,700,350, %WS_OverlappedWindow To hDlg
'gbRuler image
Control Add Graphic, hDlg, %ID_VisibleA, "", 25,25,300,300
Graphic Attach hDlg, %ID_VisibleA
Graphic Get DC To hbmpADC
Graphic Render "ruler.bmp", (0,0)-(299,299)
Graphic Bitmap New 300,300 to hSourceA
Graphic Attach hSourceA,0
Graphic Get DC to hsourceADC
Graphic Copy hDlg, %ID_VisibleA
Graphic Attach hdlg, %ID_VisibleA, redraw
'cowgirl image
Control Add Graphic, hDlg, %ID_VisibleB, "", 350,25,300,300
Graphic Attach hDlg, %ID_VisibleB
Graphic Get DC To hbmpBDC
Graphic Render "cowgirl.bmp", (0,0)-(299,299)
Graphic Bitmap New 300,300 to hSourceB
Graphic Attach hSourceB,0
Graphic Get DC to hsourceBDC
Graphic Copy hDlg, %ID_VisibleB
Graphic attach hdlg, %ID_VisibleB, redraw
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Static theta As Single
select cASE CB.MSG
Case %WM_InitDialog
SetTimer(CB.Hndl, %ID_Timer, 15, ByVal %NULL)
Case %WM_Timer
theta = theta + .05
RotateImage(theta, hsourceADC, hbmpADC) : Graphic Attach hDlg, %ID_VisibleA : Graphic ReDraw
RotateImage(theta, hsourceBDC, hbmpBDC): Graphic Attach hDlg, %ID_VisibleB : Graphic ReDraw
Case %WM_LButtonDblClk
Static rFlag As Long
rFlag = rFlag Xor 1
If rFlag Then KillTimer CB.Hndl, %ID_Timer Else SetTimer(CB.Hndl, %ID_Timer, 15, ByVal %NULL)
End Select
End Function
Function RotateImage(theta As Single, hSrc As Dword, hDest As DWord) As Long
Local X as XForm
SetGraphicsMode(hDest, %GM_Advanced)
X.em11 = cos(theta)
X.em12 = -sin(theta)
X.em21 = sin(theta)
X.em22 = cos(theta)
X.eDx = 150
X.eDy = 150
SetWorldTransform (hDest, X)
BitBlt(hDest,0,0,300,300,hSrc,0,0,%SRCCopy)
End Function
'gbs_00929
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm