杨超越的抹胸 2019-06-05 17:50 采纳率: 0%
浏览 247

Android位图采集的初级问题- -。

刚进入到位图采用的学习当中,遇到了一个逻辑问题,实在绕不过弯来。。。

public static int calculateInSampleSize(BitmapFactory.Options options,  
            int reqWidth, int reqHeight) {  
        // Raw height and width of image  
        final int height = options.outHeight;  
        final int width = options.outWidth;  
        int inSampleSize = 1;  

        if (height > reqHeight || width > reqWidth) {  
            if (width > height) {  
                inSampleSize = Math.round((float) height / (float) reqHeight);  
            } else {  
                inSampleSize = Math.round((float) width / (float) reqWidth);  
            }  
        }
        return inSampleSize;  

    } 

关于上面的代码

   if (height > reqHeight || width > reqWidth) {  
            if (width > height) {  
                inSampleSize = Math.round((float) height / (float) reqHeight);  
            } else {  
                inSampleSize = Math.round((float) width / (float) reqWidth);  
            }  
        }

是什么意思呀?为什么按照小的长度去取比例呢?我怎么感觉会出现逻辑漏洞呢?
比如原始图片是 width=400;height=200; reqwidth=400;reqheight=100;又或者reqwidth=200;reqheight=200;
那采集的图片不就成了要么缩小一半,要么不动吗?还有原始图片是正方形咋取?

  • 写回答

1条回答 默认 最新

  • qq_42739625 2019-06-06 16:12
    关注

    在长方形里面画一个最大的圆,你是按长方形的什么边来进行计算圆的半径?

    评论

报告相同问题?

悬赏问题

  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波