added empty Image constructor

This commit is contained in:
Dani The Skunk 2022-09-14 16:25:34 +02:00
parent ba4e064563
commit 4848e5f56a
1 changed files with 11 additions and 4 deletions

View File

@ -6,17 +6,24 @@ import java.nio.ByteBuffer;
public class Image { public class Image {
byte[] data; byte[] data;
int width, height; Vec2i size;
//constructors
Image(ByteBuffer buffer) { Image(ByteBuffer buffer) {
//todo: resorce system //todo: resorce system
int[] x = {0}, y = {0}, n = {0}; int[] x = {0}, y = {0}, n = {0};
var img = STBImage.stbi_load_from_memory(buffer, x, y, n, 4); var img = STBImage.stbi_load_from_memory(buffer, x, y, n, 4);
width = x[0]; size = new Vec2i(x[0], y[0]);
height = y[0]; data = new byte[x[0] * y[0] * 4];
data = new byte[width * height * 4];
img.get(data); img.get(data);
} }
Image(Vec2i size) {
this.size = size;
data = new byte[size.x * size.y * 4];
}
//getters
public byte[] getData() { public byte[] getData() {
return data; return data;
} }