B4J Question [ BitmapCreator and Canvas ] how can i draw in png image and export ?

Waldemar Lima

Well-Known Member
Licensed User
Longtime User
i am trying this code >
B4X:
    MainForm = Form1
    MainForm.RootPane.LoadLayout("main") 'Load the layout file.
    MainForm.Show
    
    cv.Initialize("cv")
    
    Dim bc As BitmapCreator
    bc.Initialize(MainForm.WindowWidth, MainForm.WindowHeight)
    Dim bmp As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "img.jpg", 600, 800, True)
    
    'cv.DrawImage(bc.Bitmap, bc.Bitmap.Width, bc.Bitmap.Width, bc.Bitmap.Width, bc.Bitmap.Height)

    cv.DrawCircle(50, 50, 20, fx.Colors.Red, True, 0)

    ImageView_Bmp.SetImage(cv.Snapshot)

but dont show nothing on imageview
 

TILogistic

Expert
Licensed User
Longtime User
tips:

Dim b As B4XBitmap = cvs.CreateBitmap

ImageView_Bmp.SetImage(b)

ImageView_Bmp.SetImage(b.Crop(0, 0, cvs.TargetRect.Width, cvs.TargetRect.Height))

but dont show nothing on imageview

Gravity = FILL or CENTER
 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
see:

cv.DrawCircle(50, 50, 20, fx.Colors.Red, True, 0)
cv.Invalidate

Dim b As B4XBitmap = cv.CreateBitmap

or

Dim b As B4XBitmap = cv.CreateBitmap.Crop(0, 0, cv.TargetRect.Width, cv.TargetRect.Height)

ImageView_Bmp.SetImage(b.Resize(350, 350, True))
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
B4X:
    MainForm = Form1
    MainForm.RootPane.LoadLayout("main") 'Load the layout file.
    MainForm.Show
    
    cv.Initialize("cv")
    
    Dim bc As BitmapCreator
    bc.Initialize(MainForm.WindowWidth, MainForm.WindowHeight)
    Dim bmp As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "img.jpg", 600, 800, True)
    
    'cv.DrawImage(bc.Bitmap, bc.Bitmap.Width, bc.Bitmap.Width, bc.Bitmap.Width, bc.Bitmap.Height)
        
    cv.DrawCircle(50, 50, 20, fx.Colors.Red, True, 0)

    ImageView_Bmp.SetImage(cv.Snapshot)

Do you need to add a circle to the image?

is what I see ... do you want that?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…