B4J Question image with canvas overlay

Iatros

Member
Licensed User
Hello,

I load an image to a ImageView. Over the ImageView is a Canvas. With clicking the mouse on the canvas I draw a circle.

I need to save the complete picture. Perhaps with a screenshot of the size and position of the ImageView ? How can I make a screenshot of a defined position ? Or is there any better way ?

Ernst
 

Attachments

  • imgcan.png
    imgcan.png
    344 KB · Views: 162

Iatros

Member
Licensed User
Thank you for your reply.

I have stolen you smiley example to make a test project. It works, I can display my image and set my circles.

On save I only save the image. The circles are painted on the panel. Could you give me another tip how to save all together ?

Second problem - in the project I switch throuch different images, which will be loaded by click on a tree. After one image is loaded I can't load another.

Thank you !

B4X:
#Region  Project Attributes
    #MainFormWidth: 1024
    #MainFormHeight: 768
#End Region

Sub Process_Globals
    Private MainForm As Form
    Private fx As JFX
   
    Private xui As XUI
    Private imgAnatomie As B4XBitmap
    Private AnatomieRect As B4XRect
    Private sizeWidth As Double = 561
    Private sizeHeight As Double = 522
    Private Panel1 As B4XView
    Private cvs As B4XCanvas
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1")
    MainForm.Show
    Create
End Sub

Sub Create
    Panel1.Width = sizeWidth
    Panel1.Height = sizeHeight
    imgAnatomie = xui.LoadBitmapResize(File.DirAssets, "Becken.jpg", sizeWidth, sizeHeight, False)
    AnatomieRect.Initialize(0, 0, sizeWidth, sizeHeight)
    cvs.Initialize(Panel1)
   
    cvs.ClearRect(cvs.TargetRect)
    cvs.DrawBitmap(imgAnatomie, AnatomieRect)
    cvs.Invalidate
End Sub

Sub Panel1_MouseClicked (EventData As MouseEvent)
    cvs.DrawCircle(EventData.X,EventData.Y,30,xui.Color_ARGB(150,255,255,255),True,1)
   
    Dim i As Image = imgAnatomie
    Dim out As OutputStream
    out = File.OpenOutput(File.DirApp, "1.jpg", False)
    i.WriteToStream(out)
    out.Close
End Sub
 
Last edited:
Upvote 0
Top