I am trying to load a png file with stbi_load_from_memory, it returns bytebuffer that is not null but failure_reason is corrupt jpeg. What I am doing wrong? This is my code:
STBImage.stbi_set_flip_vertically_on_load(true);
byte[] encoded = file.readAllBytes();
ByteBuffer encodedBuffer = BufferUtils.createByteBuffer(encoded.length);
encodedBuffer.put(encoded);
encodedBuffer.flip();
ByteBuffer byteBuffer = STBImage.stbi_load_from_memory(encodedBuffer, width, height, bpp, 4);
file.readAllBytes() is correct I tested it.
It happens when loading from file stbi_load too.