正文

图像合成(7)

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


Log.v("HEIGHTRATIO",""+heightRatio);

               Log.v("WIDTHRATIO",""+widthRatio);

 

               //如果两个比率都大于1,那么图像的一条边会大于屏幕

               if (heightRatio > 1 && widthRatio > 1){

                    if (heightRatio > widthRatio){

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

                         bmpFactoryOptions.inSampleSize = heightRatio;

                    }

                    else{

                         //若宽度比率更大,则根据它缩放

                         bmpFactoryOptions.inSampleSize = widthRatio;

                    }

               }

 

               // 对它进行真正的解码

               bmpFactoryOptions.inJustDecodeBounds = false;

               returnBmp = BitmapFactory.decodeStream(getContentResolver().

               openInputStream(imageFileUri), null, bmpFactoryOptions);

          } catch (FileNotFoundException e) {

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

          }

 

          return returnBmp;

     }

}

 


上一章目录下一章

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