简体   繁体   English

如何在Android中将位图保存到.tiff?

[英]How to save Bitmap to .tiff in Android?

I know it is possible to save bitmap to png or jpg 我知道可以将位图保存为png或jpg

now i want to save bitmap to .tiff,anybody can help? 现在我想将位图保存到.tiff,有人可以帮忙吗?

Android does not have native support for saving TIFF files. Android不支持保存TIFF文件。

You best bet would be to get the raw byte array, and then using either a Java or NDK library (like libtiff ) to save it as a TIFF. 最好的选择是获取原始字节数组,然后使用Java或NDK库(如libtiff )将其保存为TIFF。

I believe this is is a repost from here: Convert a bitmap image to an uncompressed tif image in Java 我相信这是从这里进行的转贴:在Java中将位图图像转换为未压缩的tif图像

To answer the question, the above answer suggested the following using the Java Advanced Imaging (JAI) library: 为了回答这个问题,以上答案建议使用Java Advanced Imaging(JAI)库进行以下操作:

TIFFImageWriterSpi spi = new TIFFImageWriterSpi();
ImageWriter writer = spi.createWriterInstance();
ImageWriteParam param = writer.getDefaultWriteParam();
param.setCompressionMode(ImageWriteParam.MODE_DISABLED);

ImageOutputStream ios = ImageIO.createImageOutputStream(new File("output.tif"));
writer.setOutput(ios);
writer.write(null, new IIOImage(bmp, null, null), param);

您始终可以将位图另存为.png并将其转换为.tiff

Android hasn't support for tiff images. Android不支持tiff图像。 You should use some library for working with tiff. 您应该使用一些库来处理tiff。 For example my: https://github.com/Beyka/Android-TiffBitmapFactory 例如我的: https : //github.com/Beyka/Android-TiffBitmapFactory

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM