在Android中以编程方式放大图片

use*_*192 2 android bitmap android-image android-imageview

我可以从手机中检索图片并将它们存储在一个阵列中.之后我在屏幕上显示它们.但它们都有不同的形状和大小.我想以相同的尺寸和形状显示它们.任何的想法?

photoPaths = new ArrayList<String>();   
     getAllPhotos(Environment.getExternalStorageDirectory(), photoPaths);
     images = new Bitmap[photoPaths.size()];


         apa = (AnimationPhotoView)findViewById(R.id.animation_view);
        for(int i=0;i<photoPaths.size();i++)
        {
            File imgFile = new  File(photoPaths.get(0));

            if(imgFile.exists())
            {

                images[0] = decodeFile(imgFile);}
Run Code Online (Sandbox Code Playgroud)

MAC*_*MAC 7

    Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),R.drawable.tedd);

    int width = bitmapOrg.getWidth();

    int height = bitmapOrg.getHeight();


    int newWidth = 200;

    int newHeight  = 200;

    // calculate the scale - in this case = 0.4f

     float scaleWidth = ((float) newWidth) / width;

     float scaleHeight = ((float) newHeight) / height;

     Matrix matrix = new Matrix();

     matrix.postScale(scaleWidth, scaleHeight);
     matrix.postRotate(x);
     // this will create image with new size
     Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0,width, height, matrix, true);

     iv.setScaleType(ScaleType.CENTER);
     iv.setImageBitmap(resizedBitmap);
Run Code Online (Sandbox Code Playgroud)