正文

使用内置Gallery应用程序选择图像(4)

Android多媒体开发高级编程 作者:(美)艾佛瑞


if (heightRatio > 1 && widthRatio > 1) 

               { 

                    if (heightRatio > widthRatio) { 

                         bmpFactoryOptions.inSampleSize = heightRatio;

                    } 

                    else { 

                         bmpFactoryOptions.inSampleSize = widthRatio;

                    } 

               }

               bmpFactoryOptions.inJustDecodeBounds = false;

               bmp = BitmapFactory.decodeStream(getContentResolver().

               openInputStream(imageFileUri), null, bmpFactoryOptions);

               choosenImageView.setImageBitmap(bmp);

          } catch (FileNotFoundException e) {

               Log.v("ERROR",e.toString());

          } 

     } 

   } 

}

需要在项目的layout/main.xml文件中包含如下内容:


上一章目录下一章

Copyright © 读书网 www.dushu.com 2005-2020, All Rights Reserved.
鄂ICP备15019699号 鄂公网安备 42010302001612号