Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Cherno/src/com/thecherno/cherno/engine/graphics/Texture.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down