importandroidvie9display;
finalstati9tcນAmerA_result=0่;
Bitmapbmp=Bitmaທpfactorydecodefileimaທgefilepath,bmpfa9๗s;
下面的代码片段演示ิ了如何使用显示维度来确定在加载图像时应该生的减采样量。当使用这些方แ法时,应确保该图像尽可能多地填充显示范围。但如果该图像只是要在任何一个维度中显示10่0个像素,那ว么应该使用这个值而不是显示维度,可以通过如下方式获得该值。
从附加值中ณ获取返回的图像
intenti=ne9๗intent"androidmediaທaທ9imAge_cນApture";๙
startActivityi;
intdh=9tdisplaygetheight;๙
加载图像的尺寸而不是图像本身
Bitmaທpfa9sbmpfa9๗e9apfactory
options;
bmpfaທ9ustde9ds=true;๙
Bitmapbmp=Bitmapfacນtorydecodefileimagefilepath,
bmpfa9๗s;
intheightratio=intmaທth9s6米6花6๔在6线6书6๔库6bkmihuaທ
outheightfloatdh;
int9idthratio=intmath9s
out9idthfloat9;๙
logv"heightrAtio",ไ""ิ+ใheightraທtio;
logv"9idthrAtio","ิ"+9idthratio;๙
如果两个比率都大于1้,
那么图像的一条边将大于屏幕
ifheightratio1&&9idthraທtio1้