Android Matrix to handle bitmap

Android Developer Matrix


byte[] data; // from onPictureTaken

FileOutputStream fos = new FileOutputStream(pictureFile);
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);

Matrix matrix = new Matrix();
matrix.setRotate(-90);  // rotate -90 degree
matrix.preScale(1, -1); // mirror
                
Bitmap rotateBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, false);
rotateBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);

fos.close();

0 意見: