KCBot 68 Share Posted April 12 Saw some people on the Discord having issues with this. Above your onStart create a BufferedImage like this: private BufferedImage image; Paste this on your onStart(): try { URL imageUrl = new URL("https://IMAGEHERE.COM/NOIMGURUSEIMGBB"); image = ImageIO.read(imageUrl); if (image == null) { log("Image could not be loaded."); } } catch (IOException e) { log("Error loading image: " + e.getMessage()); } Then in your onPaint() paste this: if (image != null) { graphics.drawImage(image, 10, 215, null); } The 10 and 215 are the X and Y where the image will be loaded. That should be it! Link to comment Share on other sites More sharing options...
morten1ela 19 Share Posted April 13 I strongly dislike grabbing an image from the internet rather than just plopping it in your source directory and grabbing it as such: private Image getIconImage(String iconPath){ try{ return ImageIO.read(getClass().getResourceAsStream(iconPath)); } catch (IOException e) { e.printStackTrace(); } return null; } Is there any reason not to do this? I've seen many snippets where the image is grabbed from a URL. Just curious as to why. Link to comment Share on other sites More sharing options...
FuryShark 13 Featured Comment Share Posted April 13 I've not tried it out yet but I saw this in the API: https://dreambot.org/javadocs/org/dreambot/api/utilities/Images.html#loadImage(java.lang.String) Luxe and morten1ela 2 Link to comment Share on other sites More sharing options...
Meteorite 64 Share Posted April 13 2 hours ago, morten1ela said: I strongly dislike grabbing an image from the internet rather than just plopping it in your source directory and grabbing it as such: private Image getIconImage(String iconPath){ try{ return ImageIO.read(getClass().getResourceAsStream(iconPath)); } catch (IOException e) { e.printStackTrace(); } return null; } Is there any reason not to do this? I've seen many snippets where the image is grabbed from a URL. Just curious as to why. I did this and it got denied with "You can't load images like that in SDN scripts. You need to load them from the internet." I tried using imgur but it wouldn't work so I used imgbb which works and others use. Luxe 1 Link to comment Share on other sites More sharing options...
morten1ela 19 Share Posted April 13 (edited) On 4/12/2024 at 11:03 PM, Meteorite said: I did this and it got denied with "You can't load images like that in SDN scripts. You need to load them from the internet." I tried using imgur but it wouldn't work so I used imgbb which works and others use. Oh wow I didn't know that. I don't plan on ever releasing my scripts to the SDN (partially because I suck at coding), so I guess I won't have to deal with that. Edited May 31 by morten1ela Link to comment Share on other sites More sharing options...
Luxe 41 Share Posted May 30 For other readers and googlers on this topic this is the code I used for GUI when setting an icon on a jlabel headerLogo.setIcon(new ImageIcon(loadImage("https://i.ibb.co/NZZtR7r/Finishing-Logo-LUXE.png"))); this is the code i use for loading paint image = loadImage("https://i.ibb.co/MhKGfmG/paint.jpg"); if(getSettings().shouldUseStartTile) { getSettings().startArea = new Area( new Tile(Players.getLocal().getX() + getSettings().radius, Players.getLocal().getY() + getSettings().radius), new Tile(Players.getLocal().getX() - getSettings().radius, Players.getLocal().getY() -getSettings().radius) ); } This is the key: loadImage("https://UR URL HERE!!.jpg"); https://dreambot.org/javadocs/org/dreambot/api/utilities/Images.html#loadImage(java.lang.String) represent 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Posted by FuryShark,
This is the preferred method
Recommended by Hashtag
2 reactions
Go to this post
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now