Hello Guest

[MODIFIED] stbi_load_from_memory returns corrupt jpeg

  • 0 Replies
  • 57 Views
[MODIFIED] stbi_load_from_memory returns corrupt jpeg
« on: August 17, 2019, 11:46:26 »
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:
Code: [Select]
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.
« Last Edit: August 17, 2019, 17:04:40 by MineGame159 »