-
Notifications
You must be signed in to change notification settings - Fork 0
/
Texture.java
37 lines (31 loc) · 983 Bytes
/
Texture.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
//This class contains image utilities
public class Texture {
public int[] pixels;
private String loc;
public final int SIZE;
public Texture(String location, int size) {
loc = location;
SIZE = size;
pixels = new int[SIZE * SIZE];
load();
}
private void load() {
try {
BufferedImage image = ImageIO.read(new File(loc));
int w = image.getWidth();
int h = image.getHeight();
image.getRGB(0, 0, w, h, pixels, 0, w);
} catch (IOException e) {
e.printStackTrace();
}
}
//Textures not made by me, credits to author
public static Texture wood = new Texture("res/wood.jpg", 64);
public static Texture brick = new Texture("res/redbrick.jpg", 64);
public static Texture bluestone = new Texture("res/bluestone.jpg", 64);
public static Texture stone = new Texture("res/greystone.jpg", 64);
}