NEEDED: Succinct example of rotating a canvas 90 degrees
New User. I need an uncluttered example of rotating (the current contents of) a canvas 90 degrees. I am doing this in a panel which dynamically flips height and width - that part works! I *know* this should be fairly easy to do - for someone 1% smarter than me! Thanks in advance.
Sub Button1_Click
Dim b As Bitmap
b.Initialize3(cvs.Bitmap)
Dim r As Rect
r.Initialize(0, 0, cvs.Bitmap.Width, cvs.Bitmap.Height)
cvs.DrawBitmapRotated(b, Null, r, 90)
Panel1.Invalidate
End Sub
See the attached project (click on the panel to draw on it).
Is it a requirement that the width and height be =? For oblong canvas results are not appealing. It appears that rotate works only with the center as a pivot point and on a canvas that is a square. Please correct this if wrong. Also, I assume this is a limitation of the underlying android framework and not something "correctable" within b4a.
No, you can draw the rotated bitmap wherever you want. But the pivot point is the mid point of the rectangular bitmap. You can play with transparent parts in the bitmap to 'move' the pivot.
Also, I assume this is a limitation of the underlying android framework and not something "correctable" within b4a.