Results 1 to 8 of 8

Thread: rotation

  1. #1

    Thread Starter
    Lively Member jayantkumble's Avatar
    Join Date
    Feb 2002
    Posts
    65

    rotation

    hi,
    i would like to know how to rotate an image in vb using the APIs not with DirectX.
    plz help

  2. #2
    Junior Member
    Join Date
    Aug 2002
    Location
    Phoenix
    Posts
    30
    Use neck to tilt head in a clock wise or counter clock wise fashion.
    I'm in college now.

  3. #3
    Fanatic Member Mushroom Realm's Avatar
    Join Date
    Mar 2002
    Location
    Murrieta, California
    Posts
    650
    use bitblt, and if u dont know how either search the forum, or ask a more specific question (not meant in a mean way)

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    It was my belief that PlgBlt (a sister API to BitBlt) would rotate images.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    go to www.ur.co.nz
    there is a good tutorial about this.
    Sanity is a full time job

    Puh das war harter Stoff!

  6. #6
    Hyperactive Member
    Join Date
    Aug 2002
    Posts
    352

    Re: A**hole

    Originally posted by jayantkumble
    i don't need to know how u do it.
    if u don't know something then shut ur dam mouth!
    how rude

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    A rude way to say something correct.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    Const Pi = 3.14159265359
    Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
    Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long

    Public Sub rotate(ByRef pic1 As Control, ByRef pic2 As Control, theta As Double)
    Dim c1x As Integer ' Center of pic1.
    Dim c1y As Integer ' "
    Dim c2x As Integer ' Center of pic2.
    Dim c2y As Integer ' "
    Dim a As Single ' Angle of c2 to p2.
    Dim r As Integer ' Radius from c2 to p2.

    Dim p1x As Integer ' Position on pic1.
    Dim p1y As Integer ' "
    Dim p2x As Integer ' Position on pic2.
    Dim p2y As Integer ' "
    Dim n As Integer ' Max width or height of pic2.

    blnDone = False
    ' Compute the centers.
    c1x = pic1.ScaleWidth / 2
    c1y = pic1.ScaleHeight / 2
    c2x = pic1.ScaleWidth / 2
    c2y = pic1.ScaleHeight / 2

    theta = theta * (Pi / 180)
    theta = theta - (2 * theta)

    ' Compute the image size.
    n = pic2.ScaleWidth
    If n < pic2.ScaleHeight Then n = pic2.ScaleHeight
    n = n / 2 - 1
    ' For each pixel position on pic2.
    For p2x = 0 To n
    For p2y = 0 To n
    ' Compute polar coordinate of p2.
    If p2x = 0 Then
    a = Pi / 2
    Else
    a = Atn(p2y / p2x)
    End If
    r = Sqr(1& * p2x * p2x + 1& * p2y * p2y)

    ' Compute rotated position of p1.
    p1x = r * Cos(a + theta)
    p1y = r * Sin(a + theta)

    ' Copy pixels, 4 quadrants at once.
    c0& = GetPixel(frmBattle.pbSource.hdc, c1x + p1x, c1y + p1y)
    c1& = GetPixel(frmBattle.pbSource.hdc, c1x - p1x, c1y - p1y)

    c2& = pic1.Point(c1x + p1y, c1y - p1x)
    c3& = pic1.Point(c1x - p1y, c1y + p1x)
    If c0& <> -1 Then SetPixel frmBattle.PBDest.hdc, c2x + p2x, c2y + p2y, c0&
    If c1& <> -1 Then SetPixel frmBattle.PBDest.hdc, c2x - p2x, c2y - p2y, c1&
    If c2& <> -1 Then SetPixel frmBattle.PBDest.hdc, c2x + p2y, c2y - p2x, c2&
    If c3& <> -1 Then SetPixel frmBattle.PBDest.hdc, c2x - p2y, c2y + p2x, c3&
    Next
    Next

    blnDone = True
    End Sub


    Some Code Changes Are Required In Regard To PictureBoxes but That us all Then you call this function

    Theta is Angle in degrees

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