如何从裁剪后的图像中获取实际尺寸的图像?

时间:2014-05-14 07:53:21

标签: android bitmap android-camera android-capture

我使用600x600像素裁剪图像,但是当我按照这样的位图进行位图时

if(requestCode==PIC_CROP&&resultCode == Activity.RESULT_OK)
    { 

    Bundle extras = intent.getExtras();
    //get the cropped bitmap
    Bitmap thePic = extras.getParcelable("data");
    //retrieve a reference to the ImageView
    }

我的位图高度和宽度是300x300像素,为什么它们是这样的?

我的裁剪方法:

Intent cropIntent = new Intent("com.android.camera.action.CROP"); 
    //indicate image type and Uri
    cropIntent.setDataAndType(outputFileUri, "image/*");
    //set crop properties
    cropIntent.putExtra("crop", "true");
    //indicate aspect of desired crop 
    cropIntent.putExtra("aspectX", 1);
    cropIntent.putExtra("aspectY", 1);
    //indicate output X and Y
    cropIntent.putExtra("outputX", 600);
    cropIntent.putExtra("outputY", 600);
    //retrieve data on return
    cropIntent.putExtra("return-data", true);
    //start the activity - we handle returning in onActivityResult
    startActivityForResult(cropIntent, PIC_CROP);  

和我的活动结果:

if(requestCode==PIC_CROP&&resultCode == Activity.RESULT_OK)
    { 

    Bundle extras = intent.getExtras();
    //get the cropped bitmap
    Bitmap thePic = extras.getParcelable("data");
    //retrieve a reference to the ImageView


    sourceFileUri="example.jpg"; 


    FileOutputStream out = null;
    try {
           out = new FileOutputStream(sourceFileUri);
           thePic.compress(Bitmap.CompressFormat.JPEG, 100, out);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
           try{
               out.close();
           } catch(Throwable ignore) {}
    }   
        }

我检查这样的大小:

Bitmap  photo_Share = null ; 
        try { 
            photo_Share= BitmapFactory.decodeFile(sourceFileUri,options);
        } catch (Exception e) {

        }

        int imageHeight = photo_Share.getHeight();
        int imageWidth = photo_Share.getWidth();

但是当我在画廊中看到时,我看到了我的裁剪图像600x600,但是当我查看它的代码时(我的目的是将它保存到另一个地方,它是300x300) 如何找到真实尺寸的图像?

0 个答案:

没有答案