PaulTilley
Sep 28th, 2000, 10:58 AM
RECENTLY SUBMITTED TO GENERAL VB QUESTIONS, BUT SO FAR HAVE HAD NO LUCK - CAN ANYONE HELP????????????????
Hi all
Im having problems and wondered if someone out there could help me?
I have an image in a image box which I need to rotate through 90 degree intervals.
I can put the image into a picture box and use the following code to rotate the image into another picture box.
===========
Code
===========
Public Function Rotate(Angle As Integer, OrigPic As Object, NewPic As Object)
Const PI = 3.14159265358979
Dim intX As Integer
Dim intY As Integer
Dim intX1 As Integer
Dim intY1 As Integer
Dim dblX2 As Double
Dim dblY2 As Double
Dim dblX3 As Double
Dim dblY3 As Double
Dim dblThetaDeg As Double
Dim dblThetaRad As Double
dblThetaDeg = Angle
dblThetaRad = dblThetaDeg * PI / 180
OrigPic.ScaleMode = vbPixels
NewPic.ScaleMode = vbPixels
For intX = 0 To NewPic.ScaleWidth
intX1 = intX - NewPic.ScaleWidth \ 2
For intY = 0 To NewPic.ScaleHeight
intY1 = intY - NewPic.ScaleHeight \ 2
dblX2 = intX1 * Cos(-dblThetaRad) + intY1 * Sin(-dblThetaRad)
dblY2 = intY1 * Cos(-dblThetaRad) - intX1 * Sin(-dblThetaRad)
dblX3 = dblX2 + OrigPic.ScaleWidth \ 2
dblY3 = dblY2 + OrigPic.ScaleHeight \ 2
If dblX3 > 0 And dblX3 < OrigPic.ScaleWidth - 1 And dblY3 > 0 And dblY3 < OrigPic.ScaleHeight - 1 Then
NewPic.PSet (intX, intY), OrigPic.Point(dblX3, dblY3)
End If
Next intY
Next intX
End Function
==================================
The problem occurs when I try to copy the rotated image back into the same image box that it came from - it just doesnt seem to do anything.
HELP URGENTLY
Thnx in advance
Hi all
Im having problems and wondered if someone out there could help me?
I have an image in a image box which I need to rotate through 90 degree intervals.
I can put the image into a picture box and use the following code to rotate the image into another picture box.
===========
Code
===========
Public Function Rotate(Angle As Integer, OrigPic As Object, NewPic As Object)
Const PI = 3.14159265358979
Dim intX As Integer
Dim intY As Integer
Dim intX1 As Integer
Dim intY1 As Integer
Dim dblX2 As Double
Dim dblY2 As Double
Dim dblX3 As Double
Dim dblY3 As Double
Dim dblThetaDeg As Double
Dim dblThetaRad As Double
dblThetaDeg = Angle
dblThetaRad = dblThetaDeg * PI / 180
OrigPic.ScaleMode = vbPixels
NewPic.ScaleMode = vbPixels
For intX = 0 To NewPic.ScaleWidth
intX1 = intX - NewPic.ScaleWidth \ 2
For intY = 0 To NewPic.ScaleHeight
intY1 = intY - NewPic.ScaleHeight \ 2
dblX2 = intX1 * Cos(-dblThetaRad) + intY1 * Sin(-dblThetaRad)
dblY2 = intY1 * Cos(-dblThetaRad) - intX1 * Sin(-dblThetaRad)
dblX3 = dblX2 + OrigPic.ScaleWidth \ 2
dblY3 = dblY2 + OrigPic.ScaleHeight \ 2
If dblX3 > 0 And dblX3 < OrigPic.ScaleWidth - 1 And dblY3 > 0 And dblY3 < OrigPic.ScaleHeight - 1 Then
NewPic.PSet (intX, intY), OrigPic.Point(dblX3, dblY3)
End If
Next intY
Next intX
End Function
==================================
The problem occurs when I try to copy the rotated image back into the same image box that it came from - it just doesnt seem to do anything.
HELP URGENTLY
Thnx in advance