- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTexture.java
More file actions
Latest commit
41 lines (34 loc) · 989 Bytes
/
Copy pathTexture.java
File metadata and controls
41 lines (34 loc) · 989 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
37
38
39
40
41
importjava.awt.image.BufferedImage;
importjava.awt.image.DataBufferInt;
/**
* File: Texture.java
* Created on 30.12.2023, 4:18:41
*
* @author LWJGL2
*/
publicclassTexture {
publicint[] pixelData;
publicfinalintwidth, height;
publicTexture(BufferedImagebase) {
BufferedImageimage = newBufferedImage(base.getWidth(), base.getHeight(), BufferedImage.TYPE_INT_ARGB);
{
image.getGraphics().drawImage(base, 0, 0, null);
}
width = image.getWidth();
height = image.getHeight();
pixelData = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
}
publicintgetPixel(floatx, floaty) {
returngetPixel((int) x, (int) y);
}
publicintgetPixel(intx, inty) {
intindex = x + y * width;
if (index > pixelData.length - 1) {
return0;
}
if (index < 0) {
return0;
}
returnpixelData[index];
}
}