Android Question Snapshot of the panel without B4X.view

Lakhtin_V

Active Member
Licensed User
Longtime User
Hello, I do not use the B4X technology. So I can not find an example of how to make a screen copy of the panel and all the elements on this panel. I can not use this code because I do not have B4XView objects
B4X view snapshot:
Sub Button1_Click
    
    Dim bmp As B4XBitmap = Crop_Image(Panel1, Panel1.left, Panel1.top, Panel1.width, Panel1.height )
    Dim out As OutputStream
    out = File.OpenOutput(File.DirInternal, "1.png", False)
    bmp.WriteToStream(out, 100, "PNG")
    out.Close
    
End Sub

Sub Crop_Image(V As B4XView, left As Int, top As Int, width As Int, height As Int) As Bitmap
    
    Return V.Snapshot.Crop(left, top, width, height)
    
End Sub
 

Lakhtin_V

Active Member
Licensed User
Longtime User
B4X:
Dim b As Button

'....

b.As(B4XView).Snapshot
I have activated all the libraries of XUI, but I have problems
1756131019363.png

with text labels that are on the panel next to the picture. My task is to make a snapshot of the panel containing the picture, text label and spinner.
snapshot:
    Dim pnl as B4XView, bmp as B4XBitmap
   
    pnl=Mypnl
    bmp=pnl.Snapshot
    MyBmp=bmp
1756131566955.png
 
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
You would need to use different variable names, or just do MyBmp = pnl.as(B4xView).Snapshot
Now Error.... My task make a snapshot of the panel containing the picture, text label and spinner.

B4A Version: 13.00
Parsing code. (0.19s)
Java Version: 19
Building folders structure. (0.06s)
Compiling code. Error
Error compiling program.
Error description: Current declaration does not match previous one.
Previous: {Type=F,Rank=0, RemoteObject=False}
Current: {Type=B4XFont,Rank=0, RemoteObject=True}
Error occurred on line: 246
Dim f As B4XFont = xui.CreateFont2(HintFont, LargeLabelTextSize)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
To answer the question in the first post:
If you have a variable named pnl1, which is (mistakenly) declared as Panel then you should use this code to take a snapshot:
B4X:
Dim bmp As B4XBitmap = pnl.As(B4XView).Snapshot

Any other question or issue you encounter is not relevant to this question.

And you should use latest version of B4A with an updated SDK. Otherwise you will not be able to set the targetSdkVersion as required.

And there is no such thing "B4X technologies". B4XView is a thin wrapper with multiplatform and improved API. Nothing fancy.
 
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
You almost certainly used the same bad name, "f," for a different variable elsewhere; that is, you might have declared f as Int.
Always use decent variable names!
I have a name module "F" in which my user functions are written. When the library XUI is not activated there are no problems, but when XUI is activated a problem occurs. Do you advise changing the name of my module?
 
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
To answer the question in the first post:
If you have a variable named pnl1, which is (mistakenly) declared as Panel then you should use this code to take a snapshot:
B4X:
Dim bmp As B4XBitmap = pnl.As(B4XView).Snapshot

Any other question or issue you encounter is not relevant to this question.

And you should use latest version of B4A with an updated SDK. Otherwise you will not be able to set the targetSdkVersion as required.

And there is no such thing "B4X technologies". B4XView is a thin wrapper with multiplatform and improved API. Nothing fancy.
The conflict was between the name of my module "F" and the variable "F" in the font description in the XUI Views libraries. Now everything works, thank you very much to everyone. Maybe more informative variable names should be used inside the XUI Views libraries too.
 
Upvote 0
Top