iOS Question B4i Bitmap.initialize mutable ?

MitchBu

Well-Known Member
Licensed User
Longtime User
I B4A, I use Bitmap.initializemutable to create a new bitmap so I can draw on it with a canvas.

B4i does not seem to work that way. Initializemutable is not available.

How can work around that ?
 

JordiCP

Expert
Licensed User
Longtime User
Initialize the canvas to a View. This view doesn't need to be in the layout. Only need to initialize it and assigned dimensions
Draw on it and then get the bitmap

Something similar to (untested, there may be small typos but that's the idea)
B4X:
Dim cvs As B4XCanvas
Dim myView as B4XView
myView.initialize("")
myView.width = 400      '<-- now I'm not sure if it has to be scaled with device's scale nonNormalizedValues
myView.Height = 400
cvs.Initialize(myView)
' draw here
Dim myBitmap as B4XBitmap = cvs.CreateBitmap   '<-- Here you get your bitmap
cvs.Release
 
Upvote 0

MitchBu

Well-Known Member
Licensed User
Longtime User
Initialize the canvas to a View. This view doesn't need to be in the layout. Only need to initialize it and assigned dimensions
Draw on it and then get the bitmap

Something similar to (untested, there may be small typos but that's the idea)
B4X:
Dim cvs As B4XCanvas
Dim myView as B4XView
myView.initialize("")
myView.width = 400      '<-- now I'm not sure if it has to be scaled with device's scale nonNormalizedValues
myView.Height = 400
cvs.Initialize(myView)
' draw here
Dim myBitmap as B4XBitmap = cvs.CreateBitmap   '<-- Here you get your bitmap
cvs.Release

Great. Thank you JordiCP

The only problem I have is here unknown member Initialize:

B4X:
myView.initialize("")
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
I do it like this:

B4X:
    Private MyBitmap As B4XView
    Private pnl As B4XView
    Private cvs As B4XCanvas
    
    pnl = xui.CreatePanel("")
    pnl.Width = Width
    pnl.Height = Height
    cvs.Initialize(pnl)

    MyBitmap = cvs.CreateBitmap
 
Upvote 1
Top