Jump to content

Script Logo/onPaint Background


Recommended Posts

I can't seem to load custom images to OSBot for the Logo and also for my paint. Currently I have my paint set up but I'd like to change my background to something a little nicer. I can't seem to figure out how to load the images. I've tried loading the png following this guide however I'm not exactly sure which library to import that supports main in.

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

For my IDE only 4 populate, 1 crashes the script. and the other 3 permissions are blocked. 

I've tried loading it from a url using imgur, and imgbb with no luck. Can anyone help me understand how these images need to be formatted in the directory/ loaded into the script to be drawn on the screen, and how I might be able to load an image as the bot logo. Any information would be greatly apricated, thanks for your time.

 

 

Link to comment
Share on other sites

3 hours ago, Rudolph123 said:

I can't seem to load custom images to OSBot for the Logo and also for my paint. Currently I have my paint set up but I'd like to change my background to something a little nicer. I can't seem to figure out how to load the images. I've tried loading the png following this guide however I'm not exactly sure which library to import that supports main in.

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

For my IDE only 4 populate, 1 crashes the script. and the other 3 permissions are blocked. 

I've tried loading it from a url using imgur, and imgbb with no luck. Can anyone help me understand how these images need to be formatted in the directory/ loaded into the script to be drawn on the screen, and how I might be able to load an image as the bot logo. Any information would be greatly apricated, thanks for your time.

 

 

Would be easier to see what's going on if you shared some of the code in your loading and drawing methods ^^

Imgur won't work, it's pretyt much broken for some reason.
I would suggest fetching them from an url, ibb for example (https://nl.imgbb.com/)

Best way is to save it in the OSBot/data folder and try to see if it's there else fetch and save it there :)

to fetch from a url:

    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);
            e.printStackTrace();
        }
        return null;
    }

Just do this in your onStart or something and save the image so it can be used by the onPaint :)

  • Like 1
Link to comment
Share on other sites

9 hours ago, Khaleesi said:

Would be easier to see what's going on if you shared some of the code in your loading and drawing methods ^^

Imgur won't work, it's pretyt much broken for some reason.
I would suggest fetching them from an url, ibb for example (https://nl.imgbb.com/)

Best way is to save it in the OSBot/data folder and try to see if it's there else fetch and save it there :)

to fetch from a url:

    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);
            e.printStackTrace();
        }
        return null;
    }

Just do this in your onStart or something and save the image so it can be used by the onPaint :)

Thanks a lot, it is now up and running! I went into the data folder and saved it there. However when I submit the bot to the client so people can download it. The image is only saved locally when I manually place the image in the data folder, right? Would I need to write a class to create the dir and then save the images that are located in my src or resources folder? Then call that method onStart? I'm unsure how OSBot typically wants those files to shipped as well as saved and loaded for users.

Link to comment
Share on other sites

2 hours ago, Rudolph123 said:

Thanks a lot, it is now up and running! I went into the data folder and saved it there. However when I submit the bot to the client so people can download it. The image is only saved locally when I manually place the image in the data folder, right? Would I need to write a class to create the dir and then save the images that are located in my src or resources folder? Then call that method onStart? I'm unsure how OSBot typically wants those files to shipped as well as saved and loaded for users.

If you are going to export to jar then the images must be inside the project folder, I put mine in a directory called /resources/ and then you can choose to pack these images inside the jar depending on which IDE you use

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...