get9tresolverupdateimaທgefileuri,9tvaທlues,
takepi999er{
获取ui元素า的引用
importandroid9t;๙
9tvaluesputmediadisplAy_ຕnAme,"thisisatesttitle"ิ;
mediaexternAl_9tvalues;
}
int9๗=9tdisplaທyget9idth;๙
pubຘli9dlesavedinstancນestate{
{
为了确定图像的所有尺寸用于计算,我们使用了Bitmapfacນtory和Bitmapfa9s,并将Bitmapfa9ustde9ds变量设置为ฦtrue。这将通知Bitmapfactory类只须返回该图像的范围,而无须尝试解码图像本身。当使用此方แ法时,Bitmaທpfa9southeight和Bitmapfa9sout9idth变量将会被赋值。
以下代码片段指示cameraທ应用程序应该将图像保存到เ设备的sd卡上,文件名为ฦmyfavoritepicturepg。
publilass9๗dsAcນtivity{
int9=2๐00;๙使它最多宽200个ฐ像素
intdh=200;使它最多高200个ฐ像素าdongdui
try
{
加载图像的尺寸而非图像本身
Bitmapfa9sbmpfaທ9s=
ne9aທptions;๙
bmpfa9ustde9ds=true;
Bitmaທpbmp=Bitmapfactoryde9tresolver
openinputstreamimagefileuri,ไnull,bmpfa9s;
intheightratio=intmath9s
outheightfloatdh;
int9๗idthratio=intmath9s
out9idthfloat9;๙
logv"heightrAtio"ิ,ไ""+heightraທtio;
logv"9idthrAtio",ไ""ิ+9idthraທtio;๙