added empty Image constructor
This commit is contained in:
parent
ba4e064563
commit
4848e5f56a
|
@ -6,17 +6,24 @@ import java.nio.ByteBuffer;
|
|||
|
||||
public class Image {
|
||||
byte[] data;
|
||||
int width, height;
|
||||
Vec2i size;
|
||||
|
||||
//constructors
|
||||
Image(ByteBuffer buffer) {
|
||||
//todo: resorce system
|
||||
int[] x = {0}, y = {0}, n = {0};
|
||||
var img = STBImage.stbi_load_from_memory(buffer, x, y, n, 4);
|
||||
width = x[0];
|
||||
height = y[0];
|
||||
data = new byte[width * height * 4];
|
||||
size = new Vec2i(x[0], y[0]);
|
||||
data = new byte[x[0] * y[0] * 4];
|
||||
img.get(data);
|
||||
}
|
||||
|
||||
Image(Vec2i size) {
|
||||
this.size = size;
|
||||
data = new byte[size.x * size.y * 4];
|
||||
}
|
||||
|
||||
//getters
|
||||
public byte[] getData() {
|
||||
return data;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue