Closed Orbyt closed 8 years ago
@Orbyt : thanks for your interest in pixymeta-android. The initial purpose of this repository is to have a separate API branched out from icafe for manipulating metadata of images in Android environment. This requirement came from a user. So the function of reading and writing images was not included in it. I have a separate repository for Android system to write animated GIF. If you are interested, you can find the general GIF reading class GIFReader and specific FrameReader which is a subclass of GIFReader to do exactly what you want - i.e. reading GIF image frame by frame instead of reading all the frames into memory at the same time. Unfortunately, only icafe supports this function that will not work for Android. I am thinking about porting this to a standalone repository at a later time.
For FrameReader from icafe, you can use it like this:
FrameReader reader = new FrameReader();
InputStream is = // create an input stream whatever way you can, even across the network
// Get the first frame
GIFFrame frame = reader.getGIFFrameEx(is);
// Check if frame is null, if not
BufferedImage bi = frame.getFrame();
// Keep reading the remaining frames
// This is the second frame if exists and so on until it's null, we are done
frame = reader.getGIFFrameEx(is);
@Orbyt : I have created a new repository here for this issue. The usage is similar to that given in the previous comment except that the returned type is a Bitmap instead of a BufferedImage. It doesn't matter where the InputStream is from though.
FrameReader reader = new FrameReader();
InputStream is = // create an input stream whatever way you can, even across the network
// Get the first frame
GIFFrame frame = reader.getGIFFrameEx(is);
// Check if frame is null, if not
Bitmap bmp = frame.getFrame();
// Keep reading the remaining frames
// This is the second frame if exists and so on until it's null, we are done
frame = reader.getGIFFrameEx(is);
How would you go about getting only the first frame of an animated gif? I'm assuming that this lib doesnt pull the gif over the network, but i can get the gif into a byte[] on the device, so from there how would you get only the first frame?