package org.pcsoft.android.gif;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Christoph on 26.07.2015.
 */
public final class Gif {
    public static final int LOOP_ENDLESS = -1;

    private final int width, height;
    private final int loopCount;
    private final int pixelAspectRatio;
    private final GifColorTable globalColorTable;
    private final List<GifFrame> frameList = new ArrayList<GifFrame>();

    Gif(int width, int height, int loopCount, int pixelAspectRatio, GifColorTable globalColorTable) {
        this.width = width;
        this.height = height;
        this.loopCount = loopCount;
        this.pixelAspectRatio = pixelAspectRatio;
        this.globalColorTable = globalColorTable;
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    public int getLoopCount() {
        return loopCount;
    }

    List<GifFrame> getFrameList() {
        return frameList;
    }

    public GifFrame[] getFrames() {
        return frameList.toArray(new GifFrame[frameList.size()]);
    }

    public GifColorTable getGlobalColorTable() {
        return globalColorTable;
    }

    public int getPixelAspectRatio() {
        return pixelAspectRatio;
    }
}

@@ -26,16 +26,49 @@
 d.gif;%0A%0A
+import android.graphics.Bitmap;%0A%0A
 import j
@@ -231,16 +231,1075 @@
  = -1;%0A%0A
+    public static Gif createScaledGif(Gif source, int dstWidth, int dstHeight, boolean filter) %7B%0A        final Gif gif = new Gif(dstWidth, dstHeight, source.getLoopCount(), source.getPixelAspectRatio(), source.getGlobalColorTable());%0A        for (final GifFrame frame : source.getFrameList()) %7B%0A            gif.getFrameList().add(new GifFrame(%0A                    new GifMetadata(%0A                            dstWidth * frame.getMetadata().getLeft() / frame.getMetadata().getWidth(),%0A                            dstHeight * frame.getMetadata().getTop() / frame.getMetadata().getHeight(),%0A                            dstWidth, dstHeight, frame.getMetadata().getDelay(),%0A                            frame.getMetadata().isTransparency(), frame.getMetadata().getTransparentColor(),%0A                            frame.getMetadata().getDispose()%0A                    ),%0A                    frame.getColorTable().copy(),%0A                    Bitmap.createScaledBitmap(frame.getImage(), dstWidth, dstHeight, filter)%0A            ));%0A        %7D%0A%0A        return gif;%0A    %7D%0A%0A
     priv

add gif scaling