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;
    }
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);
        }
       
        frames = framesCount;
        return image;
    }
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); } frames = framescount; return image; }