Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • How to take a screenshot without cutting off paint


    RetroBot

    Recommended Posts

    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: 626NYco.png

     

    Does anyone have any suggestions on how to capture the screenshot without losing anything on the paint?

    Link to comment
    Share on other sites

    • 2 weeks later...

    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

    • 3 weeks later...
    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

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.