osborn
V2EX  ›  Android

Android 上好用的 APNG 图片支持库

  •  
  •   osborn · Apr 3, 2019 · 15214 views
    This topic created in 2624 days ago, the information mentioned may be changed or developed.

    大家好,我写了一个在 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 replies    2019-08-08 14:03:27 +08:00
    stewforani
        1
    stewforani  
       Aug 8, 2019
    你好,麻烦去看看 我提的 issue 谢谢大神
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   922 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 21:35 · PVG 05:35 · LAX 14:35 · JFK 17:35
    ♥ Do have faith in what you're doing.