直接用嗶哩嗶哩弄的一個庫,傳送門:https://github.com/bilibili/BurstLinker
他那個庫的文檔寫的比較簡陋,所以我決定,我也寫得十分簡陋
引用:
api 'com.bilibili:burst-linker:0.0.13'
使用:
/*** @param imgList 輸入的圖片路徑列表* @param outputPath 輸出路徑,/xxx/xxx.gif* @param width 生成的gif的寬,單位像素* @param height 生成的gif的高,單位像素* @param time 每張圖片的間隔時間,單位毫秒*/public static void createGif(List<String> imgList, String outputPath, int width, int height, int time) {ALog.e("git寬高:{}x{};切換時間:{}", width, height, time);BurstLinker burstLinker = new BurstLinker();try {burstLinker.init(width, height, outputPath);for (String imgPath : imgList) {//這個量化跟抖動參數,老實說我也不明白是啥意思burstLinker.connect(BitmapFactory.decodeFile(imgPath),BurstLinker.OCTREE_QUANTIZER,BurstLinker.NO_DITHER,time);}} catch (Exception e) {e.printStackTrace();} finally {burstLinker.release();}}