Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

BufferedImage returning null

Featured Replies

For some reason the BufferedImage that I want to paint is constantly returning null even through it's not throwing any exceptions when I read it.

public class SpillsFisher extends Script {

   private BufferedImage background;

   public final void onStart() throws InterruptedException {

          try {
              background = ImageIO.read(getScriptResourceAsStream("resources/background.png"));
              log("No exceptions");
          } catch (IOException e) {
              log(e.fillInStackTrace());
          }
      }

   public void onPaint(Graphics2D g) {

          if(background != null){
              g.drawImage(background, null, 10, 10);
              log("Not null");
          } else {
              log("is null"); <-- it's always returning null here
          }
	}

Structure within IDE

F1UI8Zz.png

Structure within 7zip (It has the resources folder and the image inside)

GUjOzmt.png

I was using this post as a point of reference:

I've also tried:

background = ImageIO.read(SpillsFisher.class.getResourceAsStream("/resources/background.png"));

From

Having the same issue either way, any ideas?

What I do is fetch the image from an url like imgur :)
Save it in the Osbot/data folder and load it in next time, if it's not there download it again.
 

    public static BufferedImage getImage(Script script, String url) {
        try {
            return ImageIO.read(new URL(url));
        } catch (IOException e) {
            script.log("Failed to load image with url: " + url);
        }
        return null;
    }

 

  • Author
3 hours ago, Khaleesi said:

What I do is fetch the image from an url like imgur :)
Save it in the Osbot/data folder and load it in next time, if it's not there download it again.
 

    public static BufferedImage getImage(Script script, String url) {
        try {
            return ImageIO.read(new URL(url));
        } catch (IOException e) {
            script.log("Failed to load image with url: " + url);
        }
        return null;
    }

 

Ahah! I appreciate the response, funnily enough I was thinking about doing it this way, thank you!

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.