正文

使用内置的Camera应用程序捕获图像(8)

Android多媒体开发高级编程 作者:(美)艾佛瑞


if (resultCode == RESULT_OK) 

{

// 获取ImageView的引用

imv = (ImageView) findViewById(R.id.ReturnedImageView);

Display currentDisplay = getWindowManager().getDefaultDisplay();

int dw = currentDisplay.getWidth();

int dh = currentDisplay.getHeight();

// 加载图像的尺寸而不是图像本身

BitmapFactory.Options bmpFactoryOptions = new BitmapFactory

.Options();

bmpFactoryOptions.inJustDecodeBounds = true;

Bitmap bmp = BitmapFactory.decodeFile(imageFilePath, 

bmpFactoryOptions);

int heightRatio = (int)Math.ceil(bmpFactoryOptions.

outHeight/(float)dh);

int widthRatio = (int)Math.ceil(bmpFactoryOptions.

outWidth/(float)dw);

Log.v("HEIGHTRATIO",""+heightRatio);

Log.v("WIDTHRATIO",""+widthRatio);

// 如果两个比率都大于1,

// 那么图像的一条边将大于屏幕

if (heightRatio > 1 && widthRatio > 1) 


上一章目录下一章

Copyright © 读书网 www.dushu.com 2005-2020, All Rights Reserved.
鄂ICP备15019699号 鄂公网安备 42010302001612号