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
  • Adding an image to paint


    Aeon

    Recommended Posts

    As the title says, I'm trying to add an image to the screen for my script, but I can't seem to get it to work properly. I found this thread which has a bunch of dead screenshots so it wasn't too useful. Any help in pointing me in the direction would be greatly appreciated!

    Link to comment
    Share on other sites

    Step 1: Add this method to your main class to return Image objects from a URL:

     private Image getImage(String url) {
        try {
        	return ImageIO.read(new URL(url));
        } catch (IOException e) {
        	e.printStackTrace();
        }
        return null;
    }

    Step 2: Create an Image property to store the image using this method:

     private final Image paintBackground = getImage("https://i.imgur.com/Muw7swQ.png");

    Step 3: Draw the image using graphics in onPaint:

    if (paintBackground != null) {
    	g.drawImage(paintBackground, 30, 316, null);
    }

    Sources:

     

    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.