正文

图像存储和元数据(7)

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


if (resultCode == RESULT_OK) 

{

// Camera应用程序已经返回

// 隐藏拍照按钮

takePictureButton.setVisibility(View.GONE);

// 显示其他UI 元素

saveDataButton.setVisibility(View.VISIBLE);

returnedImageView.setVisibility(View.VISIBLE);

titleTextView.setVisibility(View.VISIBLE);

descriptionTextView.setVisibility(View.VISIBLE);

titleEditText.setVisibility(View.VISIBLE);

descriptionEditText.setVisibility(View.VISIBLE);

// 缩放图像

int dw = 200; // 使它最多宽200个像素

int dh = 200; // 使它最多高200个像素

try 

{

// 加载图像的尺寸而非图像本身

BitmapFactory.Options bmpFactoryOptions = 

new BitmapFactory.Options();

bmpFactoryOptions.inJustDecodeBounds = true;

Bitmap bmp = BitmapFactory.decodeStream(getContentResolver().

openInputStream(imageFileUri), null, 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);


上一章目录下一章

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