コメント |
@SHOW
bmp2.compress(Bitmap.CompressFormat.JPEG,90,jpg);
@END
@DIV
FileOutputStream @c:red(jpg);
try {
// 保存場所で FileOutputStream を作成
jpg = new FileOutputStream(imagePath);
if ( portrait ) {
// 縦の場合、回転して保存する
Bitmap bmp1 = BitmapFactory.decodeByteArray (data, 0, data.length);
int width = bmp1.getWidth();
int height = bmp1.getHeight();
Matrix matrix = new Matrix();
matrix.postRotate (90);
Bitmap @c:blue(bmp2) = Bitmap.createBitmap (bmp1, 0, 0, width, height, matrix, true);
// ▲ ここまでで、bmp1 を 90 度回転した、bmp2 を取得しています
// Bitmap(bmp2) を FileOutputStream(jpg) でファイル保存
@c:blue(bmp2).compress(Bitmap.CompressFormat.JPEG,90,@c:red(jpg));
}
else {
// ここは、byte[] を直接保存
jpg.write(data);
jpg.close();
}
// ギャラリーに反映
MediaScannerConnection.scanFile(
MainActivity.this,
new String[] { imagePath },
new String[] { "image/jpeg" },
null);
} catch (Exception e) {
e.printStackTrace();
}
@END
[[参考]]
@SHOW
http://logicalerror.seesaa.net/article/443100634.html(Android : 画像関連のテスト用カメラアプリ)
@END |