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 :(
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.
Re: Rotate Image (without control)
You could create a bitmap in memory, or use an StdPicture object.
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. :D
Re: Rotate Image (without control)
I'm not the OP. The quote on top is.