V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
osborn
V2EX  ›  Android

Android 上好用的 APNG 图片支持库

  •  
  •   osborn · 2019-04-03 17:19:29 +08:00 · 6216 次点击
    这是一个创建于 1840 天前的主题,其中的信息可能已经有所发展或是发生改变。

    大家好,我写了一个在 Android 上播放 APNG 动画的 library,在加载和内存方面进行了优化,有需要请取用哦。

    https://github.com/penfeizhou/APNG4Android

    • 实现 APNG 格式的解码与播放,
    • 实时解析,不产生临时文件
    • 加载速度快
    • 内存占用低
    • 支持 PNG 静态图片

    使用示例

    // 从 Asset 中加载
    APNGAssetLoader assetLoader = new APNGAssetLoader(context, "wheel.png");
     
     
    // 从 Resource 中加载
    APNGResourceLoader resourceLoader = new APNGResourceLoader(context, R.drawable.sample);
     
     
    // 从文件系统加载
    APNGFileLoader fileLoader = new APNGFileLoader("/sdcard/Pictures/wheel.png");
     
     
    // 创建 Drawable
    APNGDrawable apngDrawable = new APNGDrawable(assetLoader);
     
     
    // 设置后自动播放
    imageView.setImageDrawable(apngDrawable);
     
     
    // 设置重复次数
    apngDrawable.setLoopLimit(10);
     
     
    // 已实现 Animatable2Compat 接口
    drawable.registerAnimationCallback(new Animatable2Compat.AnimationCallback() {
        @Override
        public void onAnimationStart(Drawable drawable) {
            super.onAnimationStart(drawable);
        }
    });
    

    满意的话给个 star,谢谢🙏

    1 条回复    2019-08-08 14:03:27 +08:00
    stewforani
        1
    stewforani  
       2019-08-08 14:03:27 +08:00
    你好,麻烦去看看 我提的 issue 谢谢大神
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3668 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 10:56 · PVG 18:56 · LAX 03:56 · JFK 06:56
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.