Bitmap.createBitmap java.lang.IllegalArgumentException: width and height must be > 0 问题解决

java.lang.IllegalArgumentException: width and height must be > 0 


在postraotate之前需要设置转换矩形区域

旋转时要判断旋转角度是否大于0,否则不做旋转。


缺一报错

Matrix mt = new Matrix();

				float delta = angle - lastAngle;
				lastAngle = angle;
				Log.e("test", bmpW + "_____" + bmpH);
				RectF rect = new RectF(0, 0, bmpW, bmpH);
				mt.setRectToRect(rect, rect, Matrix.ScaleToFit.CENTER);
				if(angle > 0) mt.postRotate(angle);

Bitmap resizeBmp = Bitmap.createBitmap(b, 0, 0, bmpW, bmpH, mt, true);



你可能感兴趣的:(Bitmap.createBitmap java.lang.IllegalArgumentException: width and height must be > 0 问题解决)