Sub Name: DrawRoundBitmap
Description: This code uses Path object to draw a round bitmap at the center of a transparent mutable bitmap.
Dependencies: JavaObject
Tags: round bitmap, ClipPath
Description: This code uses Path object to draw a round bitmap at the center of a transparent mutable bitmap.
B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim cvs As Canvas = CreateBitmap
DrawRoundBitmap(cvs, LoadBitmap(File.DirAssets, "1.jpg"))
Activity.SetBackgroundImage(cvs.Bitmap)
End Sub
Sub CreateBitmap As Canvas
Dim bmp As Bitmap
bmp.InitializeMutable(200dip, 200dip)
Dim cvs As Canvas
cvs.Initialize2(bmp)
Dim r As Rect
r.Initialize(0, 0, bmp.Width, bmp.Height)
cvs.DrawRect(r, Colors.Transparent, True, 0)
Dim p As Path
p.Initialize(0, 0)
Dim jo As JavaObject = p
Dim x = 100dip, y = 100dip, radius = 100dip As Float
jo.RunMethod("addCircle", Array As Object(x, y, radius, "CW"))
cvs.ClipPath(p)
Return cvs
End Sub
Sub DrawRoundBitmap (cvs As Canvas, bmp As Bitmap)
Dim r As Rect
r.Initialize(0, 0, cvs.Bitmap.Width, cvs.Bitmap.Height)
cvs.DrawBitmap(bmp, Null, r)
End Sub
Dependencies: JavaObject
Tags: round bitmap, ClipPath
Last edited: