Sebastian Kürten05/16/2022, 8:41 PM
Kirill Grouchnikov05/16/2022, 8:51 PM
is your friend
Sebastian Kürten05/16/2022, 9:27 PM
and was able to render and store to file the way you suggested. I'm still curious whether it's possible or planned to use the testing API similar to the way its possible with Android. I found Maven artifact
and was able to change most imports on the Android example in the blog post above so that they resolve. What does not seem to be available is
, I'm assuming it's going to be added eventually:
Why I'm interested in this: the testing API also has support for simulating clicks on UI elements, so I guess it will help making series of screenshots from various parts of the UI without needing to manipulate state internally, but can be manipulated by simulated mouse and key events.
onRoot() .captureToImage() .asAndroidBitmap() .save(file)
BufferedImage image = new BufferedImage( component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB ); // call the Component's paint method, using // the Graphics object of the image. component.paint( image.getGraphics() );
on the graphics obtained from a buffered image. Kind of cool and wondering if there's potentially a way to trick compose into rendering into an offscreen buffer, too. That would allow to capture screenshots of an app in production (say with some magic keyboard shortcut) without using external screenshot tools.