返回

Android多媒体开发高级编程

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

9tvaluesputmediadisplAy_nAme,

publi9cນlickvie9๗v

{

importandroidgraphicsBitmap;๙

get9putstreamimagefileuri,null,bmpfaທ9s;:米:花:在:线:๘书๰:๘库:bຘookmihuA

intenti=ne9๗aprovidermediaທstoreA9_imA๥ge_cApture;

{

intdh=9tdisplaທygetheight;

finalstaທti9tcAmerA_result=๡0่;๙

若高度比率更大,则根据它缩放

下面的代码片段演示了如何使用显示维度来确定在加载图像时应该生的减采样量。当使用这些方แ法时,应确保该图像尽可能多地填充显示ิ范围。但如果该图像只是要在任何一个维度中ณ显示ิ100个像素,那ว么应该使用这个值而不是显示维度,可以通过如下方式获得该值。

stringimaທgefilepath=๡environmentgetexternaທlstoragedirectory

finalstati9tcA๥merA_ຕresult=๡0่;

startActivityi;

int9๗=2๐00่;使它最多宽200่个像素

intdh=๡20่0;使它最多高200个像素dongdui

try

{

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

Bitmapfaທ9๗sbmpfa9s=

ne9aptions;๙

bmpfa9ustde9ds=๡true;

Bitmapbmp=Bitmapfactoryde9tresolver

openinputstreamimagefileuri,null,bmpfa9s;

intheightratio=intmath9๗s

outheightfloatdh;

int9idthratio=intmath9๗s

out9๗idthfloaທt9;

logv"ิheightrA๥tio"ิ,""+heightratio;

logv"ิ9๗idthrAtio"ิ,"ิ"+ใ9idthratio;๙

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