From 4848e5f56ac5bbb6d6c10e6ca7536317706c2d31 Mon Sep 17 00:00:00 2001 From: Dani The Skunk Date: Wed, 14 Sep 2022 16:25:34 +0200 Subject: [PATCH] added empty Image constructor --- com/danitheskunk/skunkworks/Image.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/com/danitheskunk/skunkworks/Image.java b/com/danitheskunk/skunkworks/Image.java index cff56d8..154955d 100644 --- a/com/danitheskunk/skunkworks/Image.java +++ b/com/danitheskunk/skunkworks/Image.java @@ -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; }