-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTexture.java
More file actions
36 lines (32 loc) · 896 Bytes
/
Texture.java
File metadata and controls
36 lines (32 loc) · 896 Bytes
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
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Texture {
public int[] pixels;
private String loc;
private final int SIZE;
private final int imgWidth;
private final int imgHeight;
public Texture(String location, int w, int h) {
loc = location;
SIZE = w;
pixels = new int[w * h];
imgWidth = w;
imgHeight = h;
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();
}
}
public int getSize() {
return SIZE;
}
}