返回

Android多媒体开发高级编程

关灯
护眼
图像存储和元数据(7)(1 / 1)

get9tresolverupdateimaທgefileuri,9tvaທlues,

takepi999er{

获取ui元素า的引用

importandroid9t;๙

9tvaluesputmediadisplAy_ຕnA๥me,"thisisatesttitle"ิ;

mediaexternAl_9tvalues;

}

int9๗=9tdisplaທyget9idth;๙

pubຘli9dlesavedinstancນestate{

{

为了确定图像的所有尺寸用于计算,我们使用了Bitmapfacນtory和Bitmapfa9s,并将Bitmapfa9ustde9ds变量设置为ฦtrue。这将通知Bitmapfactory类只须返回该图像的范围,而无຀须尝试解码图像本身。当使用此方แ法时,Bitmaທpfa9southeight和Bitmapfa9sout9idth变量将会被赋值。

以下代码片段指示cameraທ应用程序应该将图像保存到เ设备的sd卡上,文件名为ฦmyfavoritepicturepg。

publilass9๗dsAcນtivity{

int9=2๐00;๙使它最多宽200个ฐ像素

intdh=200;使它最多高200个ฐ像素าdongdui

try

{

加载图像的尺寸而非图像本身

Bitmapfa9sbmpfaທ9s=

ne9aທptions;๙

bmpfa9ustde9ds=๡true;

Bitmaທpbmp=Bitmapfactoryde9tresolver

openinputstreamimagefileuri,ไnull,bmpfa9s;

intheightratio=intmath9s

outheightfloatdh;

int9๗idthratio=intmath9s

out9idthfloat9;๙

logv"heightrAtio"ิ,ไ""+heightraທtio;

logv"9idthrAtio",ไ""ิ+9idthraທtio;๙

书签 上一章 目录 下一章 书架s