我正在尝试实现“扩展”按钮以使图像适合所选边界。
public void extendS(View v){
ImageView iv = current;
double width = gallery.getWidth();
double hight= gallery.getHeight();
double aspect = (width+0)/(hight+0);
Log.d("aspect", "w: "+width+" h: "+hight+" a: "+aspect);
if (aspect>1){
hight/=aspect;
}else{
width*=aspect;
}
Bitmap b = ((BitmapDrawable) iv.getDrawable()).getBitmap();
// Matrix matrix = new Matrix();
Log.d("aspect", "w: "+width+" h: "+hight+" a: "+aspect);
Bitmap scale = Bitmap.createBitmap(b, 0, 0, (int)width, (int)hight);
iv.setImageBitmap(scale);
我收到的错误:07-16 12:26:36.855: E/AndroidRuntime(12647): Caused by: java.lang.IllegalArgumentException: y + height must be <= bitmap.height() 这个错误在我看来有点奇怪观点看法