环境:android 4.3 (注意对于android4.4版本解码出来不正确,除了第一帧正确外,其余的都是显示不同的地方) 通用版本见: android 开发对gif解码(适配android 4.2、4.3、4.4版本)
使用方法:
void showGif2()
{
gifDecoder = new GifImageDecoder();
try {
gifDecoder.read(this.getResources().openRawResource(R.drawable.b17)); //这是Gif图片资源
int size =gifDecoder.getFrameCount();
for(int i=0;i> 3;
}
public int getSizeOfGlobalColorTable() {
return (bytes[10] & 0x07);
}
public int getBackgroundColorIndex() {
return bytes[11] & 0xFF;
}
public int getPixelAspectRatio() {
return bytes[12];
}
public int[] getGlobalColorTable() {
if (getGlobalColorTableFlag() == 0) {
return new int[0];
}
int[] colors = new int[(int) Math.pow(2, getSizeOfGlobalColorTable() + 1)];
for (int i = 0; i < colors.length; i++) {
colors[i] = ((bytes[13 + (i * 3)] & 0xFF) 5;
}
public int getReserved() {
return (bytes[9] & 0x18) >> 2;
}
public int getSizeOfLocalColorTable() {
return bytes[9] & 0x03;
}
public int[] getLocalColorTable() {
if (getLocalColorTableFlag() == 0) {
return new int[0];
}
int[] colors = new int[(int) Math.pow(2, getSizeOfLocalColorTable() + 1)];
for (int i = 0; i < colors.length; i++) {
colors[i] = ((bytes[10 + (i * 3)] & 0xFF) 5;
}
public int getDisposalMothod() {
return (bytes[3] & 0x1C) >> 2;
}
public int getUserInputFlag() {
return (bytes[3] & 0x02) >> 1;
}
public int getTransparentColorFlag() {
return (bytes[3] & 0x01);
}
public int getDelayTime() {
return (bytes[4] & 0xFF) + ((bytes[5] & 0xFF) |