获取位图宽度和高度在同一位图中是变化的

时间:2013-09-08 12:43:46

标签: java android bitmap

在我的应用程序中,我需要找出位图的精确尺寸(以像素为单位)。位图的实际尺寸为600x583。当我打电话

mBitmap.getWidth(); mBitmap.getHeight();

我得到300x292作为位图的尺寸。

我再次调用相同的位图 mBitmap.getWidth(); mBitmap.getHeight();

然后我得到240x233。每次比例相同。但这不是正确的价值。我怎样才能克服这个问题?

mBitmap=BitmapFactory.decodeResource(getResources(), R.drawable.birdsketchfinal2).copy(Config.ARGB_8888, true);

        height=mBitmap.getHeight();
        width=mBitmap.getWidth();

        //In here I get 300X292

        disWidth = getResources().getDisplayMetrics().widthPixels;
        disHeight = getResources().getDisplayMetrics().heightPixels;

        modified=((float)disWidth/(float)width)*height;

        mBitmap= Bitmap.createScaledBitmap(mBitmap, disWidth, (int)modified, true);

        height=mBitmap.getHeight();
        width=mBitmap.getWidth();

                    //I here I get 240x233

0 个答案:

没有答案