'number of times to redraw image per rotation
'in other words 360/NUM_TURNS = # of degrees per
'each turn of the image


Dim dAngle As Double

Const NUM_TURNS = 36
Const PI = 3.14159265358979
Const CENTER_X = 4000

Const SRCCOPY = &HCC0020

Private Declare Function StretchBlt Lib "gdi32"_
 (ByVal hdc As Long, ByVal x As Long, ByVal y As Long,_
 ByVal nWidth As Long, ByVal nHeight As Long,_
 ByVal hSrcDC As Long, ByVal xSrc As Long,_
 ByVal ySrc As Long, ByVal nSrcWidth As Long,_
 ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Declare Function BitBlt Lib "gdi32"_
 (ByVal hDestDC As Long, ByVal x As Long,_
 ByVal y As Long, ByVal nWidth As Long,_
 ByVal nHeight As Long, ByVal hSrcDC As Long,_
 ByVal xSrc As Long, ByVal ySrc As Long,_
 ByVal dwRop As Long) As Long


Private Sub Form_Load()

picForward.AutoSize = True
picBackward.AutoSize = True
picBuffer.Width = picForward.Width
picBuffer.Height = picForward.Height
picDisplay.Width = picForward.Width
picDisplay.Height = picForward.Height
picBuffer.Visible = False
picForward.Visible = False
picBackward.Visible = False
picBuffer.AutoRedraw = True
picForward.AutoRedraw = True
picBackward.AutoRedraw = True
picDisplay.AutoRedraw = True
picForward.BorderStyle = 0
picBackward.BorderStyle = 0
picBuffer.BorderStyle = 0
picDisplay.BorderStyle = 0

End Sub


Private Sub Timer1_Timer()

'assume that 0 degrees is when the 
'picture is facing forward

picBuffer.Cls

If Cos(dAngle * PI / 180) >= 0 Then
    Call StretchBlt(picBuffer.hdc,_
    (picForward.Width - Abs(Cos(dAngle * PI / 180)_
    * picForward.Width)) / (2 * Screen.TwipsPerPixelX),_
    0, Abs(Cos(dAngle * PI / 180) * picForward.Width)_
    / Screen.TwipsPerPixelX, picForward.Height /_
    Screen.TwipsPerPixelY, picForward.hdc, 0, 0,_
    picForward.Width / Screen.TwipsPerPixelX,_
    picForward.Height / Screen.TwipsPerPixelY, SRCCOPY)
ElseIf Cos(dAngle * PI / 180) < 0 Then
    Call StretchBlt(picBuffer.hdc,_
    (picBackward.Width - Abs(Cos(dAngle * PI / 180)_
    * picBackward.Width)) / (2 * Screen.TwipsPerPixelX),_
    0, Abs(Cos(dAngle * PI / 180) * picBackward.Width) /_
    Screen.TwipsPerPixelX, picBackward.Height /_
    Screen.TwipsPerPixelY, picBackward.hdc, 0, 0,_
    picBackward.Width / Screen.TwipsPerPixelX,_
    picBackward.Height / Screen.TwipsPerPixelY, SRCCOPY)
End If

Call BitBlt(picDisplay.hdc, 0, 0,_
  picBuffer.Width / Screen.TwipsPerPixelX,_
  picBuffer.Height / Screen.TwipsPerPixelY,_
  picBuffer.hdc, 0, 0, SRCCOPY)

picDisplay.Refresh

'increment angle and make sure it stays 
'between 0 and 360

dAngle = dAngle + 360 / NUM_TURNS
dAngle = dAngle Mod 360

End Sub

'(c) Richard Yarnell
'    ryarnell@andrew.cmu.edu
Best Hair Transplants | Insurance Policy Study | Yahoo Dating | Process Checks Through Website | Low Cost Voip Service