Skip to content Skip to sidebar Skip to footer

Rotate Large Bitmap Using Matrix

When i rotate my large bitmap using matrix so application crash,i don't want to using canvas. i am using below code,please help me Thanks Matrix mMatrix = new Matrix(); rotateRight

Solution 1:

I think you need to set options for that

BitmapFactory.Optionsoptions=newBitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeByteArray(data , 0, data .length,options);

more explanations at docs

OR try with below code

try {
            //Decode image size
            BitmapFactory.Optionso=newBitmapFactory.Options();
            o.inJustDecodeBounds = true;
            BitmapFactory.decodeByteArray(data , 0, data .length,o);

            //The new size we want to scale tofinalint REQUIRED_WIDTH=WIDTH;
            finalint REQUIRED_HIGHT=HIGHT;
            //Find the correct scale value. It should be the power of 2.int scale=1;
            while(o.outWidth/scale/2>=REQUIRED_WIDTH && o.outHeight/scale/2>=REQUIRED_HIGHT)
                scale*=2;

            //Decode with inSampleSize
            BitmapFactory.Optionso2=newBitmapFactory.Options();
            o2.inSampleSize=scale;
            BitmapfinalBitmap=  BitmapFactory.decodeByteArray(data , 0, data .length,o2);
        }
            catch (Exception e) {
         }

Post a Comment for "Rotate Large Bitmap Using Matrix"