9tvaluesputmediadisplAy_nAme,
publi9cນlickvie9๗v
{
importandroidgraphicsBitmap;๙
get9putstreamimagefileuri,null,bmpfaທ9s;:米:花:在:线:๘书:๘库:bຘookmihuA
intenti=ne9๗aprovidermediaທstoreA9_imAge_cApture;
{
intdh=9tdisplaທygetheight;
finalstaທti9tcAmerA_result=0่;๙
若高度比率更大,则根据它缩放
下面的代码片段演示了如何使用显示维度来确定在加载图像时应该生的减采样量。当使用这些方แ法时,应确保该图像尽可能多地填充显示ิ范围。但如果该图像只是要在任何一个维度中ณ显示ิ100个像素,那ว么应该使用这个值而不是显示维度,可以通过如下方式获得该值。
stringimaທgefilepath=environmentgetexternaທlstoragedirectory
finalstati9tcAmerA_ຕresult=0่;
startActivityi;
int9๗=2๐00่;使它最多宽200่个像素
intdh=20่0;使它最多高200个像素dongdui
try
{
加载图像的尺寸而非图像本身
Bitmapfaທ9๗sbmpfa9s=
ne9aptions;๙
bmpfa9ustde9ds=true;
Bitmapbmp=Bitmapfactoryde9tresolver
openinputstreamimagefileuri,null,bmpfa9s;
intheightratio=intmath9๗s
outheightfloatdh;
int9idthratio=intmath9๗s
out9๗idthfloaທt9;
logv"ิheightrAtio"ิ,""+heightratio;
logv"ิ9๗idthrAtio"ิ,"ิ"+ใ9idthratio;๙