RetroBot 35 Share Posted May 25, 2020 I use the code from this post: /** * Takes a screenshot and writes the image as PNG to the dreambot folder * inside of a folder as the name of the script */ public void screenshot() { File file = new File(getManifest().name()); BufferedImage image = getClient().getCanvasImage(); try { if (!file.exists() || !file.isDirectory()) { log("Creating script folder"); file.mkdir(); } log("Saving screenshot..."); ImageIO.write(image, "png", new File(String.format("%s/%s.png", getManifest().name(), System.currentTimeMillis()))); } catch (Exception e) { e.printStackTrace(); } } And half the time when it takes a screenshot the paint looks a little messed up like this: Does anyone have any suggestions on how to capture the screenshot without losing anything on the paint? Link to comment Share on other sites More sharing options...
handspiker2 0 Share Posted June 2, 2020 Does it only happen on the bank screen? Alternatively you could redo the painting on the BufferedImage. It would be less than ideal and would depend on how you are handling paint, but could work in theory. public void screenshot() { File file = new File(getManifest().name()); BufferedImage image = getClient().getCanvasImage(); try { if (!file.exists() || !file.isDirectory()) { log("Creating script folder"); file.mkdir(); } log("Saving screenshot..."); // Repaint onPaint(image.getGraphics()); ImageIO.write(image, "png", new File(String.format("%s/%s.png", getManifest().name(), System.currentTimeMillis()))); } catch (Exception e) { e.printStackTrace(); } } Link to comment Share on other sites More sharing options...
RetroBot 35 Author Share Posted June 22, 2020 On 6/2/2020 at 1:33 PM, handspiker2 said: Does it only happen on the bank screen? Alternatively you could redo the painting on the BufferedImage. It would be less than ideal and would depend on how you are handling paint, but could work in theory. public void screenshot() { File file = new File(getManifest().name()); BufferedImage image = getClient().getCanvasImage(); try { if (!file.exists() || !file.isDirectory()) { log("Creating script folder"); file.mkdir(); } log("Saving screenshot..."); // Repaint onPaint(image.getGraphics()); ImageIO.write(image, "png", new File(String.format("%s/%s.png", getManifest().name(), System.currentTimeMillis()))); } catch (Exception e) { e.printStackTrace(); } } Sorry, didn't notice your reply. It happens on every screen due to the paint having a refresh rate of 25ms or whatever. I eventually did find a work around though. Instead of grabbing the client's canvas I used the robot's create screen capture method. This isn't really ideal since it isn't linked up to the client at all since it takes a screenshot of whatever is on the screen in the specified rectangle, but it worked for my purposes. BufferedImage image = new Robot().createScreenCapture(new Rectangle(595, 304, 486, 330)); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.