Android实现多张图片合成GIF
2016-11-18 16:19
621 查看
原文链接:http://blog.csdn.net/u011102153/article/details/52122722
工程地址:https://github.com/LineChen/GifMaker
工具类:
主要参数:图片地址集合、GIF播放每张图片的时间间隔、宽度、高度。
方法中最重要的类是AnimatedGifEncoder,这个类在Glide图片加载库中有,所以工程中也添加了Glide依赖。
工程地址:https://github.com/LineChen/GifMaker
工具类:
public static String createGif(String filename, List<String> paths, int fps, int width, int height) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); AnimatedGifEncoder localAnimatedGifEncoder = new AnimatedGifEncoder(); localAnimatedGifEncoder.start(baos);//start localAnimatedGifEncoder.setRepeat(0);//设置生成gif的开始播放时间。0为立即开始播放 localAnimatedGifEncoder.setDelay(fps); if (paths.size() > 0) { for (int i = 0; i < paths.size(); i++) { Bitmap bitmap = BitmapFactory.decodeFile(paths.get(i)); Bitmap resizeBm = ImageUtil.resizeImage(bitmap, width, height); localAnimatedGifEncoder.addFrame(resizeBm); } } localAnimatedGifEncoder.finish();//finish File file = new File(Environment.getExternalStorageDirectory().getPath() + "/LiliNote"); if (!file.exists()) file.mkdir(); String path = Environment.getExternalStorageDirectory().getPath() + "/LiliNote/" + filename + ".gif"; FileOutputStream fos = new FileOutputStream(path); baos.writeTo(fos); baos.flush(); fos.flush(); baos.close(); fos.close(); return path; }
主要参数:图片地址集合、GIF播放每张图片的时间间隔、宽度、高度。
方法中最重要的类是AnimatedGifEncoder,这个类在Glide图片加载库中有,所以工程中也添加了Glide依赖。
相关文章推荐
- Android实现多张图片合成GIF
- Android gif图片的解码与合成
- Android 中使用ImageView实现播放Gif图片功能
- opencv2实现多张图片路线路牌(直线和圆)检测并将处理后的图片合成视频_计算机视觉大作业2
- android调用系统分享实现朋友圈同时分享文字和图片(可多张)
- Android加载Gif图片的一般方法:Movie实现
- Android开发实现网络加载多张图片并可以滑动
- java图片处理——多张图片合成一张Gif图片并播放或Gif拆分成多张图片
- Android 图片合成:添加蒙板效果 不规则相框 透明度渐变效果的实现
- 一分钟实现Android多张图片选择
- android studio中使用android-gif-drawable开源项目实现gif图片的显示
- 实现android上传多张图片和文字给php后台
- android 实现微信分享多张图片的功能
- android开发 实现同时显示png/jpg 等bitmap图片还可以显示gif图片,有效防止OOM
- Android 实现播放本地GIF图片
- Android实现图片上传,可以选择多张图片,缩放预览,拍照上传等
- Android轻松实现播放Gif图片
- Android加载Gif图片的一般方法:Movie实现
- Android一键转发图片多张图片到微信,朋友圈功能实现
- Android轻松实现播放Gif图片