How to rotate an image from "onPictureTaken" without an "Exception from memory"?

I read a lot of posts there? But I do not find the right answer.

I am trying to do something like the following:

@Override
public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera) {
    try {


        Bitmap bitmap = BitmapFactory.decodeByteArray(paramArrayOfByte, 0,
        paramArrayOfByte.length);

        int width = bitmap.getWidth();
        int height = bitmap.getHeight();

        FileOutputStream os = new ileOutputStream(Singleton.mPushFilePath);

        Matrix matrix = new Matrix();
        matrix.postRotate(90);
        Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width,
            height, matrix, false);

        resizedBitmap.compress(Bitmap.CompressFormat.JPEG, 95, os);
        os.close();
        ...

Is there a way to rotate an image without using BitmapFactory? I want to rotate the image without losing quality!

+5
source share
1 answer

Perhaps you can make the picture rotated as you want using Camera.setDisplayOrientation? Check the camera box for Android . Next, explore Camera.Parameters.setRotation (). One of these methods should do the trick for you.

, 95 Bitmap.compress, 100 .

, Camera.Parameters.setPictureSize() (, 3Mpx). .. 8Mpx? Camera.Parameters.getSupportedPictureSizes(), .

+4

All Articles