diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4c84063c1996914323c2019224daae41e5afeed4..98d889c4f1b68e0b105365782b9077a19072f7d1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,6 +9,7 @@ + + val fos = FileOutputStream(jpgFilePath) + BufferedOutputStream(fos).use { bos -> if (bitmap.compress(Bitmap.CompressFormat.JPEG, 80, bos)) { bos.flush() } + bos.close() + } + fos.close() + } catch (e: IOException) { + e.printStackTrace() + } finally { + bitmap!!.recycle() + } + } + + fun pngToJpg2(pngFilePath: String, jpgFilePath: String) { + val bitmap: Bitmap? = BitmapFactory.decodeFile(pngFilePath) + try { + val bos = BufferedOutputStream(FileOutputStream(jpgFilePath)) + bitmap?.run { + compress(Bitmap.CompressFormat.JPEG, 100, bos) + bos.flush() } + bos.close() } catch (e: IOException) { e.printStackTrace() + } finally { + bitmap!!.recycle() } }