Android Question Rotating images about a point other than the center

mdehrnsb

Member
Licensed User
Longtime User
Is there a way to rotate an image on a canvas about a point other than the center? For example, I need to rotate the image at the center-point at the bottom edge of the image.
 

eurojam

Well-Known Member
Licensed User
Longtime User
you can try ABExtDrawing Lib. There you can play around with a rotation and trasnlation matrix to achieve this:
B4X:
Sub Globals
        Dim ExDraw As ABExtDrawing
        Dim MyCanvas As Canvas
        Dim Panel1 As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
      Activity.LoadLayout("1")
      MyCanvas.Initialize(Panel1)  
   End If
   Dim m As ABMatrix
   m.Initialize
   m.postRotate(45)
   m.postTranslate(10dip,10dip)

   Dim b As Bitmap
   Dim pnt As ABPaint
 
   b.Initialize(File.DirAssets,"1.png")
   ExDraw.drawBitmap4(MyCanvas,b,m,pnt)
  
End Sub

https://www.b4x.com/android/forum/threads/abextdrawing-1-0.14638/
 
Upvote 0

wonder

Expert
Licensed User
Longtime User
LibGDX's Batch.Draw3() does it as well.
 
Upvote 0
Top