B4J Question Save part of pane as an image

ThRuST

Well-Known Member
Licensed User
Any advice on how to do this? let's say we have an imageview on top of a pane. Now we want to save it as as image, so the area of pane1 becomes the new image.

As you pour water into a cup, it becomes an image of B4J, perhaps with the jAWTRobot library :)
 

ThRuST

Well-Known Member
Licensed User
@Enrique Gonzalez R Thank you so much, oh high master of programming :) Actually I was reffering to a source code example about a favicon. You might want to look at the source (v1.1) which you can find here

I will try your solution with pane1. The imageview is on top of it.
 

ThRuST

Well-Known Member
Licensed User
newicon.png

I managed to save it to the drive, but what if I want to also handle it through memory directly? something like

imageview2.setimage = pane1.snapshot(getpixel..width height blabla)

This is what I've got
B4X:
' Generate new icon
            Dim out As OutputStream = File.OpenOutput("c:\", "newicon.png", False)
            Pane1.Snapshot.WriteToStream(out)
 

ThRuST

Well-Known Member
Licensed User
@Cableguy Thanks. I loaded it back in which isn't optimal but I will use it in the v1.2 update of favicon example.
If you provide a little example I can bake it in into the example and credit you too :)

this is what I've got so far
B4X:
' Generate new icon
                Private DriveName As String = "c:\"
                Private IconFileName As String = "newicon.png"
            
                Private out As OutputStream = File.OpenOutput(DriveName, IconFileName, False)
                Pane1.Snapshot.WriteToStream(out)
              
                ' Load image
                ImageView2.SetImage(fx.LoadImage(DriveName, IconFileName))
 

ThRuST

Well-Known Member
Licensed User
I see. Well I updated the favicon example to v1.2 so you might want to play with it once you get the net back, it turned out into an icon-maker :)
 
Top