android 开发 解码gif图片,获取每帧bitmap

您所在的位置:网站首页 安卓gif转换为动态壁纸 android 开发 解码gif图片,获取每帧bitmap

android 开发 解码gif图片,获取每帧bitmap

2024-04-13 06:30| 来源: 网络整理| 查看: 265

环境: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)


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3