将位图转换为jpeg android

时间:2016-01-03 02:24:16

标签: android

我在Android中拍摄照片拍摄的位图。照片位于Bitmap中。我必须将此位图转换为JPEG而不会有任何损失。我尝试了下面的代码,

val file = File(filePath)
profileImageBitmap.compress(Bitmap.CompressFormat.JPEG,100,FileOutputStream(file))

但是当我使用RoundedBitmapFactoryDrawable设置jpeg图像时,捕获的图像非常小。我想要jpeg的确切位图。有人可以帮我弄这个吗?感谢。

1 个答案:

答案 0 :(得分:0)

我认为这可能有用:

  

使用此:

grep -i testCron.php /var/log/syslog | tail -1
     

你可以使用它:

Bitmap bmp = null;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.jpeg, 100, stream);
byte[] byteArray = stream.toByteArray();
     

以及更多信息请访问here

请阅读How to convert a bitmap to a jpeg file in Android?了解更多解决方案

希望有所帮助