CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2007
    Posts
    1

    Question Rotate Image (without control)

    I need to write a function inside a module that doesn't use a PictureBox to rotate an image. I've found some API stuff that almost does this, but they all use a PictureBox to save the bitmap.

    Can someone please help me out with this? I'm a bit lost when it comes to funky API stuff

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Rotate Image (without control)

    You want code that "doesn't use a PictureBox to rotate an image."

    Is that like code that 'doesn't even do anything?" Not hard to write I guess.

    Where is your image? If it's somewhere, it can be rotated.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Rotate Image (without control)

    You could create a bitmap in memory, or use an StdPicture object.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  4. #4
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    516

    Re: Rotate Image (without control)

    Quote Originally Posted by Ryuichi
    I need to write a function inside a module that doesn't use a PictureBox to rotate an image. I've found some API stuff that almost does this, but they all use a PictureBox to save the bitmap.
    Dump the bitmap into a 2 dimensional array. Then just transpose the rows and columns. This should give you the basic gist, to rotate clockwise you need to change the write order:
    Code:
    Private Function RotateArrayCCW(bSource() As Byte) As Byte()
    
        Dim lOuter As Long, lInner As Long, bOut() As Byte
    
        On Error Resume Next
        ReDim bOut(UBound(bSource, 2), UBound(bSource))
        If Err.Number <> 0 Then
            'Invalid source array.
            Err.Clear
            Exit Function
        Else
            For lOuter = LBound(bSource) To UBound(bSource)                 'Loop rows.
                For lInner = LBound(bSource, 2) To UBound(bSource, 2)       'Loop columns.
                    bOut(lInner, lOuter) = bSource(lOuter, lInner)          'Write the new values.
                Next lInner
            Next lOuter
            RotateArrayCCW = bOut
        End If
    
    End Function
    Quote Originally Posted by dglienna
    Is that like code that 'doesn't even do anything?" Not hard to write I guess.
    I like that idea. Maybe I'll write a Rube Goldberg program.
    Last edited by Comintern; December 21st, 2007 at 02:37 PM. Reason: Change Quote tag

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Rotate Image (without control)

    I'm not the OP. The quote on top is.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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