android - 如何以编程方式在Android中将PNG图像转换为GIF

标签 android android-imageview

我正在开发一个应用程序,我想在其中将图像从 png 格式转换为 gif 格式,请帮助我或对此提出一些建议

最佳答案

使用 Gif 编码器 类来实现。 例如,您可以使用 https://github.com/nbadal/android-gif-encoder/blob/master/GifEncoder.java

ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
  AnimatedGifEncoder encoder = new AnimatedGifEncoder();
  encoder.start(bos);
  encoder.addFrame(image);
  encoder.finish();
  byte[] array = bos.toByteArray();

  // Save to file
  File output = new File("output.gif");
  FileOutputStream fos = new FileOutputStream(output.getPath());
  fos.write(array);
  fos.close();

关于android - 如何以编程方式在Android中将PNG图像转换为GIF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24428263/

相关文章:

android - 在 RelativeLayout 中使用 ImageView 重复图像

Android Studio SDK 与 Windows 不兼容

android - android Listview中多个点之间的距离

android - 您可以在 Android 中的相同两个设备之间建立多个蓝牙连接吗?

Android getColumName 和 getColumnIndex

android - 在android中自定义 ImageView 上绘制

android - imageview android中图像的大小

java - "Don' t show anymore"ThickBox in Android Activity

android - 如何使 AppCompatImageView 在小部件中工作?

Android:制作滑动 ImageView