正文

圖像存儲(chǔ)和元數(shù)據(jù)(7)

Android多媒體開發(fā)高級(jí)編程 作者:(美)艾佛瑞


if (resultCode == RESULT_OK) 

{

// Camera應(yīng)用程序已經(jīng)返回

// 隱藏拍照按鈕

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個(gè)像素

int dh = 200; // 使它最多高200個(gè)像素

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 ? 讀書網(wǎng) ranfinancial.com 2005-2020, All Rights Reserved.
鄂ICP備15019699號(hào) 鄂公網(wǎng)安備 42010302001612號(hào)