BurstLinker是一个简单的C++GIF编码库。可以在Android,Windows,Linux或其他平台上轻松使用它。
安卓平台
下载:Gradle:
implementation 'com.bilibili:burst-linker:latest-version'构建环境
AndroidStudio3.0.1
NDKr16
基本用法int delayMs = 1000;String filePath = getExternalCacheDir() + File.separator + "out.gif";BurstLinker burstLinker = new BurstLinker();try { burstLinker.init(width, height, filePath); Bitmap colorBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(colorBitmap); Paint p = new Paint(); int[] colors = new int[]{0xFFF00000, 0xFFFFFF00, 0xFFFFFFFF}; for (int color : colors) { p.setColor(color); canvas.drawRect(0, 0, width, height, p); burstLinker.connect(colorBitmap, BurstLinker.OCTREE_QUANTIZER, BurstLinker.NO_DITHER, 0, 0, delayMs); }} catch (GifEncodeException e) { e.printStackTrace();} finally { burstLinker.release();}
评论