rokkonet

PC・Androidソフトウェア・アプリの開発・使い方に関するメモ

android開発 Bitmapのjpegへの変換

2020 Apr. 26.
2020 Mar. 21.

// Prepare myBmp of Bitmap before the codes below.
//     BitMap -> ByteArrayOutputStream -> JPEG
byte[]  byteArrayMyImage;  // prepare instance of ByteArray on memory to store finished JPEG
ByteArrayOutputStream outStream = new ByteArrayOutputStream();  // prepare instance of OutputStream in ByteArray
myBmp.compress(Bitmap.CompressFormat.JPEG, 80, outStream);  // convert BitMap to OutputStream in ByteArray
byteArrayMyImage = outStream.toByteArray();  // convert OutputStream to ByteArray on memory