【问题标题】:How can I save my image as BMP format?如何将我的图像保存为 BMP 格式?
【发布时间】:2011-10-02 09:28:47
【问题描述】:

我知道我应该使用压缩方法来保存位图文件。

FileOutputStream fos = new FileOutputStream(imagefile);

bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();

但我想将图像保存为 bmp 格式,而“Bitmap.CompressFormat”仅支持 PNG 和 JPEG。如何将我的图像文件保存为 BMP 格式?

谢谢,

【问题讨论】:

标签: android image save bmp


【解决方案1】:

你可以使用copyPixelsToBuffer

将位图像素存储到缓冲区中,然后将缓冲区写入 sd。

【讨论】:

  • 我做到了,但没有得到结果:FileOutputStream fos = new FileOutputStream(imagefile); ByteBuffer bf = ByteBuffer.allocate(width * height * 4); bitmap.copyPixelsToBuffer(bf); fos.write(bf.array()); fos.flush(); fos.close(); return true;
  • 对不起,我误解了文档。对不起
猜你喜欢
  • 2012-04-16
  • 1970-01-01
  • 2022-12-12
  • 2021-10-06
  • 1970-01-01
  • 1970-01-01
  • 2021-08-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多