Im loading a gif like this
public static Buffers getGifBuffer(@Nullable NativeImage.Format format, ByteBuffer buffer) throws IOException {
if (format != null && !format.isWriteable()) {
throw new UnsupportedOperationException("Don't know how to read format " + format);
} else {
MemoryStack memoryStack = MemoryStack.stackPush();
try {
IntBuffer intBuffer = memoryStack.mallocInt(1);
IntBuffer intBuffer2 = memoryStack.mallocInt(1);
IntBuffer intBuffer3 = memoryStack.mallocInt(1);
IntBuffer intBuffer4 = memoryStack.mallocInt(1);
PointerBuffer pointerBuffer = memoryStack.callocPointer(1);
int form = format == null ? 0 : channel(format);
ByteBuffer byteBuffer = STBImage.stbi_load_gif_from_memory(buffer, pointerBuffer, intBuffer, intBuffer2, intBuffer3, intBuffer4, form);
if (byteBuffer == null) {
System.out.println(STBImage.stbi_failure_reason());
throw new IOException("Could not load image: " + STBImage.stbi_failure_reason());
}
return new Buffers(byteBuffer, intBuffer.get(0), intBuffer2.get(0), pointerBuffer.get(0), intBuffer4.get(0), form);
} catch (Throwable var9) {
if (memoryStack != null) {
try {
memoryStack.close();
} catch (Throwable var8) {
var9.addSuppressed(var8);
}
}
throw var9;
}
}
}
then i try to render a frame of the gif using the pointer that i get like this
public static long getOffset(int width, int height, int frame_index, int channel_count) {
return (long) width * height * frame_index * channel_count;
}
but im getting the frame that im searching + all the previous ones.