Results 1 to 2 of 2

Thread: URGENT HELP REQD on Rotating an Image

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2000
    Location
    UK
    Posts
    199
    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

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Make sure that the autoredraw property of the picture boxes are setted to true. And that you do a refresh command after drawing:
    Code:
    Picture1.Refresh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width