本篇文章用于实现Android的gif动画
第一步:找到需要实现动画效果的gif动画图片
第二步:新建Android工程
第三步:添加实现gif动画的源文件
1.GifDecoder.xml
public class GifDecoder
{
private int E0;
private int E1[];
private int E2;
private int E6;
private boolean E7;
private int E8[];
private int width;
private int height;
private int ED;
private boolean EE;
private boolean EF;
private int F0[];
private int F1;
private boolean F2;
private int F3;
private long F4;
private int F5;
private static final int F6[] = { 8, 8, 4, 2 };
private static final int F8[] = { 0, 4, 2, 1 };
int curFrame;
int poolsize;
int FA;
byte C2[];
int FB;
int FC;
int FD;
public GifDecoder(byte abyte0[])
{
E0 = -1;
E1 = new int[280];
E2 = -1;
E6 = 0;
E7 = false;
E8 = null;
width = 0;
height = 0;
ED = 0;
EE = false;
EF = false;
F0 = null;
F1 = 0;
F5 = 0;
curFrame = 0;
C2 = abyte0;
poolsize = C2.length;
FA = 0;
}
public boolean moreFrames()
{
return poolsize - FA >= 16;
}
public void nextFrame()
{
curFrame++;
}
public Bitmap decodeImage()
{
return decodeImage(curFrame);
}
public Bitmap decodeImage(int i)
{
if (i <= E0)
{
return null;
}
if (E0 < 0)
{
if (!E3())
{
return null;
}
if (!E4())
{
return null;
}
}
do
{
if (!E9(1))
{
return null;
}
int j = E1[0];
if (j == 59)
{
return null;
}
if (j == 33)
{
if (!E7())
{
return null;
}
}
else if (j == 44)
{
if (!E5())
{
return null;
}
Bitmap image = createImage();
E0++;
if (E0 < i)
{
image = null;
}
else
{
return image;
}
}
}
while (true);
}
public void clear()
{
C2 = null;
E1 = null;
E8 = null;
F0 = null;
}
private Bitmap createImage()
{
int i = width;
int j = height;
int j1 = 0;
int k1 = 0;
int ai[] = new int[4096];
int ai1[] = new int[4096];
int ai2[] = new int[8192];
if (!E9(1))
{
return null;
}
int k = E1[0];
int[] image = new int[width * height];
int ai3[] = E8;
if (EE)
{