Try this:
Image buffer = Image.createImage(width, height);
Graphics g = buffer.getGraphics();
g.translate(-cmp.getAbsoluteX(), -cmp.getAbsoluteY());
cmp.paintComponent(g);
g.translate(cmp.getAbsoluteX(), cmp.getAbsoluteY());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ImageIO.getImageIO().save(buffer, stream,
ImageIO.FORMAT_PNG, 1);
byte[] byteArray = stream.toByteArray();
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/ef1df356-1fb4-40c7-91da-1ea699856601%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.