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.

cant upload background images

Featured Replies

I'm currently following Explv's tutorials on scripting and was following his paint tutorial and I was having issues when it came to uploading a background image. When i had the code in a normal script no background image would be uploaded but I wouldn't get any errors so to try and trouble shoot i created a script containing only the paint code to try and upload the background image but it wont even register as a script when i export it to the osbot script folder. I would really appreciate if someone can point out what I may be doing wrong. Using Eclipse IDE here's what i wrote: 

package core;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.osbot.rs07.script.Script;

public class BackgroundTest extends Script {

BufferedImage background;

@Override
public void onStart() {

try {
background = ImageIO.read(BackgroundTest.class.getResourceAsStream("/resources/background.png")); 
} catch(IOException e) {
log(e);
}
}


@Override
public final int onLoop() throws InterruptedException {
// TODO Auto-generated method stub
return 0;
}


public void onPaint(Graphics2D g) {
if(background != null) {
g.drawImage(background, null, 300, 300);
}
}
}

 


 

Edited by vladbuff

  • Author
1 hour ago, Muffins said:

you need an @ScriptManifest big dog 

okay that's huge i can actually launch the script now but it still doesn't draw an imagine onto the screen is there something else I need to do to actually get a background image to show up?

3 minutes ago, vladbuff said:

okay that's huge i can actually launch the script now but it still doesn't draw an imagine onto the screen is there something else I need to do to actually get a background image to show up?

drawImage(Image img,
                   int x, int y,
                   ImageObserver observer);

It looks like you're inputting a null x coord, try doing 

 

g.drawImage(background, 300, 300, null);
  • Author

https://gyazo.com/6fa217daea890867e9591e369da18e31

 

this is a screenshot of where the resources folder is located and the image inside of it if that's relevant, i also looked at another thread with a seemingly similar problem where the solution was to verify that the image is getting exported correctly which it is

4 minutes ago, Muffins said:
drawImage(Image img,
                   int x, int y,
                   ImageObserver observer);

It looks like you're inputting a null x coord, try doing 

 

g.drawImage(background, 300, 300, null);

will try that now!

 

2 minutes ago, vladbuff said:

https://gyazo.com/6fa217daea890867e9591e369da18e31

 

this is a screenshot of where the resources folder is located and the image inside of it if that's relevant, i also looked at another thread with a seemingly similar problem where the solution was to verify that the image is getting exported correctly which it is

will try that now!

 

the img might need to be in the /osbot/data/ folder as well.

  • Author
Just now, Muffins said:

the img might need to be in the /osbot/data/ folder as well.

changing the x coords didnt seem to affect the outcome there isnt an image printing and i do have the same background.png saved in osbot/data/ unfortunately i might just try changing the image im trying to use as as a background image and see if that helps

14 hours ago, vladbuff said:

changing the x coords didnt seem to affect the outcome there isnt an image printing and i do have the same background.png saved in osbot/data/ unfortunately i might just try changing the image im trying to use as as a background image and see if that helps

Try something like this in you onStart to load an image and draw that image in your onPaint :)

public static File imageFile = new File(System.getProperty("user.home") + File.separator + "OSBot" + File.separator + "Data" + File.separator + "image.png");

try {
    BufferedImage image = ImageIO.read(imageFile);
} catch (IOException e) {
    e.printStackTrace();
}
 

Edited by Khaleesi

  • Author
10 hours ago, Khaleesi said:

Try something like this in you onStart to load an image and draw that image in your onPaint :)

public static File imageFile = new File(System.getProperty("user.home") + File.separator + "OSBot" + File.separator + "Data" + File.separator + "image.png");

try {
    BufferedImage image = ImageIO.read(imageFile);
} catch (IOException e) {
    e.printStackTrace();
}
 

alright so i commented out the old BufferedImage code and implemented this into my onstart method but it doesnt let me use the value of image in my onPaint method am i putting everything into the right spot of my code or do i need to change the typing on my onStart or onPaint from void to something else?

package core;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(name = "BackgroundTest", author = "VladBuff", info = "", version = 0.1, logo = "")

public class BackgroundTest extends Script {
	
	//BufferedImage background;
	
	public static File imageFile = new File(System.getProperty("user.home") + File.separator + "OSBot" + File.separator + "Data" + File.separator + "background.png");

	@Override
	public void onStart() {
			
		try {
		    BufferedImage image = ImageIO.read(imageFile);
		} catch (IOException e) {
		    e.printStackTrace();
		}
	
		
		/*
		try {
			
			background = ImageIO.read(BackgroundTest.class.getResourceAsStream("/resources/background.png"));			
		} catch(IOException e) {
			log(e);
		}
		*/
		}
		 
	
	@Override
	public final int onLoop() throws InterruptedException {
		// TODO Auto-generated method stub
		return 0;
	}
		
		public void onPaint(Graphics2D g) {
			
			
		if(image != null) {
			g.drawImage(image, null, 0, 0);
			
		}
	}
				
}

 

On 1/6/2024 at 8:55 PM, vladbuff said:

alright so i commented out the old BufferedImage code and implemented this into my onstart method but it doesnt let me use the value of image in my onPaint method am i putting everything into the right spot of my code or do i need to change the typing on my onStart or onPaint from void to something else?

package core;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(name = "BackgroundTest", author = "VladBuff", info = "", version = 0.1, logo = "")

public class BackgroundTest extends Script {
	
	//BufferedImage background;
	
	public static File imageFile = new File(System.getProperty("user.home") + File.separator + "OSBot" + File.separator + "Data" + File.separator + "background.png");

	@Override
	public void onStart() {
			
		try {
		    BufferedImage image = ImageIO.read(imageFile);
		} catch (IOException e) {
		    e.printStackTrace();
		}
	
		
		/*
		try {
			
			background = ImageIO.read(BackgroundTest.class.getResourceAsStream("/resources/background.png"));			
		} catch(IOException e) {
			log(e);
		}
		*/
		}
		 
	
	@Override
	public final int onLoop() throws InterruptedException {
		// TODO Auto-generated method stub
		return 0;
	}
		
		public void onPaint(Graphics2D g) {
			
			
		if(image != null) {
			g.drawImage(image, null, 0, 0);
			
		}
	}
				
}

 

You obviously have to put that variable outside the onStart to use it in the onPaint 
Just like u did with the background variable :)

  • Author
8 hours ago, Khaleesi said:

You obviously have to put that variable outside the onStart to use it in the onPaint 
Just like u did with the background variable :)

I AM AN IDIOT THANK YOU I appreciate you letting me figure it out a bit it has been solved

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.