diff --git a/Cherno/src/com/thecherno/cherno/engine/graphics/Texture.java b/Cherno/src/com/thecherno/cherno/engine/graphics/Texture.java index 10355cd..a245d34 100644 --- a/Cherno/src/com/thecherno/cherno/engine/graphics/Texture.java +++ b/Cherno/src/com/thecherno/cherno/engine/graphics/Texture.java @@ -34,6 +34,21 @@ public static Texture load(String path) { return new Texture(width, height, pixels); } + public static Texture load(URL url) { + int width = 0, height = 0; + int[] pixels = null; + try { + BufferedImage image = ImageIO.read(url); + width = image.getWidth(); + height = image.getHeight(); + pixels = new int[width * height]; + image.getRGB(0, 0, width, height, pixels, 0, width); + } catch (IOException e) { + e.printStackTrace(); + } + return new Texture(width, height, pixels); + } + public int getWidth() { return width; }