Android Question Wow to convert a panel in png picture?

alan1968

Active Member
Licensed User
hello :)

Is it possible you to convert a panel to a png picture ?,without going through the realization of a library

Thx!
 

alan1968

Active Member
Licensed User
the panel convert in png contains multiple element (button, panel, label, ....)
I would stoker appearance in a png to make a preview in a slide before displaying this panel.
I currently displayed in a slide panels with all their items, is long enough to show (more than 38 panels with many elements) resize include +- 3sec

I looked at your library camera as inspiration

i find that but no work ....
B4X:
package com.exemple.b4a;
import java.awt.Graphics;
import java.awt.Panel;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;

@ShortName("pnltopng")
@Version(1.00f)
@Author("Alan")

public class pnl_to_png {
    public static void usage(Panel p , String f) {
        BufferedImage bi = new BufferedImage(p.getSize().width, p.getSize().height, BufferedImage.TYPE_INT_ARGB);
        Graphics g = bi.createGraphics();
        p.paint(g);
        g.dispose();
        try{
            ImageIO.write(bi,"png",new File(f));
            }
        catch (Exception e)
        {}
    }

}
 
Last edited:
Top