Results 1 to 5 of 5

Thread: Hard one ( I think .. )

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    208

    Wink

    I have a picture or an image box ( I dont care )
    and the picture inside is a CARD ...

    that's easy ..

    But I want to rotate my picture or image box ( or the image in whitout do a new one each time )

    so
    the card normaly is like that:

    ||

    but now, I want the card in thoses 3 possitions :


    // ' top of the card on the top
    \\ ' top of the card on the top
    // ' top of the card on the bottom
    \\ ' top of the card on the bottom


    so I can do a table liek that:

    /\
    \/ and put a deck of card in the real way ...


    understand ??
    no ..

    just DO A PICTURE ROTATION whit a FUNCTION !



  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    208
    No one can help me !?!?
    no know how to change a picture of orientation..

    like:
    1
    4_|_2
    |
    3



    Comme on guy !
    I don't want to do
    4 deck !


  3. #3
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    India
    Posts
    298
    Hi,
    I haven't used it....so Im not sure abt the syntax....think u can use the BitBlt API for what u want.


    Hope this helps, at least a bit(or even a byte)! )

  4. #4
    Guest

    Thumbs down

    You need to use PlgBlt (parallelogram bit block transfer) to rotate, but this is only avaialble in NT. To do it in 95/98, you need to do some good old trigonometry to rotate.

    Umm, I've got some sample code somewhere....

    This is a sample I've ripped of the web ages ago. No idea who originally wrote it (my apologies to those concerned)

    Throw on thee buttons and two picture boxes, and paste this code into the form:

    Code:
    Const SRCCOPY = &HCC0020
    Const Pi = 3.14159265359
    Private Declare Function SetPixel Lib "GDI32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
    Private Declare Function GetPixel Lib "GDI32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long
    Private Declare Function StretchBlt Lib "GDI32" (ByVal hDC As Long, ByVal X%, 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
    
    Sub Form_Load()
    Picture1.ScaleMode = 3
    Picture2.ScaleMode = 3
    End Sub
    
    
    Sub Command1_Click()
    'flip horizontal
    Picture2.Cls
    px% = Picture1.ScaleWidth
    py% = Picture1.ScaleHeight
    retval% = StretchBlt(Picture2.hDC, px%, 0, -px%, py%, Picture1.hDC, 0, 0, px%, py%, SRCCOPY)
    End Sub
    
    
    Sub Command2_Click()
    'flip vertical
    Picture2.Cls
    px& = Picture1.ScaleWidth
    py& = Picture1.ScaleHeight
    retval& = StretchBlt(Picture2.hDC, 0, py&, px&, -py&, Picture1.hDC, 0, 0, px&, py&, SRCCOPY)
    End Sub
    
    Sub Command3_Click()
    'rotate 45 degrees
    Picture2.Cls
    Call bmp_rotate(Picture1, Picture2, 3.14 / 4)
    End Sub
    
    
    Sub bmp_rotate(pic1 As PictureBox, pic2 As PictureBox, ByVal theta!)
    ' bmp_rotate(pic1, pic2, theta)
    ' Rotate the image in a picture box.
    '   pic1 is the picture box with the bitmap to rotate
    '   pic2 is the picture box to receive the rotated bitmap
    '   theta is the angle of rotation
    Dim c1x As Long, c1y As Long
    Dim c2x As Long, c2y As Long
    Dim a As Single
    Dim p1x As Long, p1y As Long
    Dim p2x As Long, p2y As Long
    Dim n As Long, r   As Long
    
    c1x = pic1.ScaleWidth \ 2
    c1y = pic1.ScaleHeight \ 2
    c2x = pic2.ScaleWidth \ 2
    c2y = pic2.ScaleHeight \ 2
    
    If c2x < c2y Then n = c2y Else n = c2x
    n = n - 1
    pic1hDC& = pic1.hDC
    pic2hDC& = pic2.hDC
    
    For p2x = 0 To n
      For p2y = 0 To n
        If p2x = 0 Then a = Pi / 2 Else a = Atn(p2y / p2x)
        r = Sqr(1& * p2x * p2x + 1& * p2y * p2y)
        p1x = r * Cos(a + theta!)
        p1y = r * Sin(a + theta!)
        c0& = GetPixel(pic1hDC&, c1x + p1x, c1y + p1y)
        c1& = GetPixel(pic1hDC&, c1x - p1x, c1y - p1y)
        c2& = GetPixel(pic1hDC&, c1x + p1y, c1y - p1x)
        c3& = GetPixel(pic1hDC&, c1x - p1y, c1y + p1x)
        If c0& <> -1 Then xret& = SetPixel(pic2hDC&, c2x + p2x, c2y + p2y, c0&)
        If c1& <> -1 Then xret& = SetPixel(pic2hDC&, c2x - p2x, c2y - p2y, c1&)
        If c2& <> -1 Then xret& = SetPixel(pic2hDC&, c2x + p2y, c2y - p2x, c2&)
        If c3& <> -1 Then xret& = SetPixel(pic2hDC&, c2x - p2y, c2y + p2x, c3&)
      Next
      t& = DoEvents()
    Next
    End Sub

  5. #5
    Guest
    Sorry, the smilies should be &)

    - gaffa

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