CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    Nov 1999
    Location
    France
    Posts
    29

    Is it impossible to rotate a picture in an IMAGE Control???

    All I've ever read about picture rotation speaks about a picture box control but never with an image control...

    help me


  2. #2
    Join Date
    Mar 2001
    Posts
    8

    Re: Is it impossible to rotate a picture in an IMAGE Control???

    Would you mind to provide me the details of rotate a picture box


  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Is it impossible to rotate a picture in an IMAGE Control???

    Const SRCCOPY = &HCC0020
    Const Pi = 3.14159265359
    Private Declare Function SetPixel Lib "GDI32" (ByVal hDC As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal crColor As Long) As Long
    Private Declare Function GetPixel Lib "GDI32" (ByVal hDC As Integer, ByVal X As Integer, ByVal Y As Integer) As Long
    Private Declare Function StretchBlt% Lib "GDI32" (ByVal hDC%, ByVal X%, ByVal Y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal XSrc%, ByVal YSrc%, ByVal nSrcWidth%, ByVal nSrcHeight%, ByVal dwRop&)

    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 Integer, c1y As Integer
    Dim c2x As Integer, c2y As Integer
    Dim a As Single
    Dim p1x As Integer, p1y As Integer
    Dim p2x As Integer, p2y As Integer
    Dim n As Integer, r As Integer

    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


    Iouri Boutchkine
    iouri@hotsheet.com
    Iouri Boutchkine
    iouri@hotsheet.NOSPAM.com

  4. #4
    Join Date
    May 2010
    Posts
    6

    Re: Is it impossible to rotate a picture in an IMAGE Control???

    hello,

    i am trying to rotate an image on my report. i came across this on the internet and i tried it but it doesn't work with me. i get the error that he can't find the method scalemode.

    any suggestions?

  5. #5
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Is it impossible to rotate a picture in an IMAGE Control???

    Apart from reviving an ancient thread (10 years old), what did you do? You did not provide any information about what exactly are your premises.
    \.ScaleMode is a property available to Forms and PictureBox controls. Maybe you have an Image control which has no ScaleMode. The above sample code seems to relate to PictureBox controls.

  6. #6
    Join Date
    May 2010
    Posts
    6

    Re: Is it impossible to rotate a picture in an IMAGE Control???

    i am using an image control. i have a report that is based on a table. In that table i have a field that contains a path where the picture is. but the problem is that the pictures are horizontal and i need them vertically on my report.

    i looked in Access 2007, but i can't find the picturebox control. i always get the image control.

    is the picturebox control still available in access 2007?

  7. #7
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Is it impossible to rotate a picture in an IMAGE Control???

    So this is VBA you are talking about.
    I got Office 2003 only here, but can't find a PictureBox either... it seems the PictureBox is intrinsic to VB6.
    Maybe this article and download helps:
    http://www.lebans.com/imageclass.htm
    There is a picturebox emulation for use in Access.

  8. #8
    Join Date
    May 2010
    Posts
    6

    Re: Is it impossible to rotate a picture in an IMAGE Control???

    i opened that link that you posted. but it seems that that is for access 97.

  9. #9
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Is it impossible to rotate a picture in an IMAGE Control???

    As far as I could load the example with Access 2003 there were no severe problems. It is only VBA code, which hasn't changed much since Access95. It describes a class which wraps an Image control and extends its capabilities to draw on it, giving it an hDC (device context handle).
    However it does not feature the Scale/Scalemode of a real picturebox, so it might require some adaptions to the code you have. Instead of ScaleHeight and ScaleWidth you have to use Height and Width.

  10. #10
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Is it impossible to rotate a picture in an IMAGE Control???

    I forgot: In the code you posted, these lines would lead to an error.
    Code:
    pic1hDC% = pic1.hDC
    pic2hDC% = pic2.hDC
    You'd have to use longs for the hDC
    Code:
    pic1hDC& = pic1.hDC
    pic2hDC& = pic2.hDC
    All in all the above code uses no single Dim statement, so it relies upon Option Explicit being off.
    I recommend to change this and declare all variables explicitly to spot errors.

  11. #11
    Join Date
    May 2010
    Posts
    6

    Re: Is it impossible to rotate a picture in an IMAGE Control???

    i've been looking to some alternatieves and i found MODI. does anyone have expierence with this?

  12. #12
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Is it impossible to rotate a picture in an IMAGE Control???

    Never heard of it, but please point it out so as we can take a look.

  13. #13
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Is it impossible to rotate a picture in an IMAGE Control???

    Doesn't Access 2007 use dot net?
    Always use [code][/code] tags when posting code.

  14. #14
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Is it impossible to rotate a picture in an IMAGE Control???

    Well, there is still VBA in it, as I think. I only got 2003 to test for now...

  15. #15
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Is it impossible to rotate a picture in an IMAGE Control???

    I looked online, looks like it still uses regular VBA, I too am using 2003
    Always use [code][/code] tags when posting code.

Page 1 of 2 12 LastLast

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

Featured