// TODO: Support APNG animated images?
public Image LoadImageAnim(String fileName, int frames) {
        Image image = new Image();
        int framesCount = 1;
        if (SUPPORT_FILEFORMAT_GIF) {
            if (rCore.IsFileExtension(fileName, ".gif")) {
                byte[] fileData = null;
                try{
                    BufferedImage tmpImg = ImageIO.read(new File(fileName));
                    ByteArrayOutputStream os = new ByteArrayOutputStream();
                    ImageIO.write(tmpImg, rCore.GetFileExtension(fileName).substring(1), os);
                    fileData = os.toByteArray();
                } catch (IOException exception) {
                    exception.printStackTrace();
                }
                if (fileData != null) {
                    try (MemoryStack stack = MemoryStack.stackPush()) {
                        IntBuffer widthBuffer = stack.mallocInt(1);
                        IntBuffer heightBuffer = stack.mallocInt(1);
                        IntBuffer compBuffer = stack.mallocInt(1);
                        PointerBuffer delaysBuffer = null;
                        IntBuffer framesBuffer = stack.mallocInt(1);
                        framesBuffer.put(framesCount).flip();
                        ByteBuffer fileDataBuffer = MemoryUtil.memAlloc(fileData.length);
                        fileDataBuffer.put(fileData).flip();
                        ByteBuffer imgBuffer = STBImage.stbi_load_gif_from_memory(fileDataBuffer, delaysBuffer,
                                                                                  widthBuffer, heightBuffer, framesBuffer, compBuffer, 4);
                        image.width = widthBuffer.get();
                        image.height = heightBuffer.get();
                        image.mipmaps = 1;
                        image.format = RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
                        if (imgBuffer != null) {
                            byte[] bytes = new byte[imgBuffer.capacity()];
                            for (int i = 0; i < bytes.length; i++) {
                                bytes[i] = imgBuffer.get();
                            }
                            image.setData(bytes);
                        }
                        fileData = null;
                    }
                }
            }
        }
        else{
            image = LoadImage(fileName);
        }
        // TODO: Support APNG animated images?
        frames = framesCount;
        return image;
    }
image = LoadImage(fileName);
}
// TODO: Support APNG animated images?
frames = framesCount;
return image;
image.setData(bytes);
}
fileData = null;
}
}
}
}
else{
image = LoadImage(fileName);
}
// TODO: Support APNG animated images?
frames = framesCount;
return image;
}
widthBuffer, heightBuffer, framesBuffer, compBuffer, 4);
image.width = widthBuffer.get();
image.height = heightBuffer.get();
image.mipmaps = 1;
image.format = RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
if (imgBuffer != null) {
byte[] bytes = new byte[imgBuffer.capacity()];
for (int i = 0; i < bytes.length; i++) {
bytes[i] = imgBuffer.get();
}
image.setData(bytes);
}
fileData = null;
}
}
}
}
else{
image = LoadImage(fileName);
}
// TODO: Support APNG animated images?
frames = framesCount;
return image;
}