Android创建缩放和旋转位图
以下代码用于从另一位图bmpSrc创建旋转和缩放位图:Android创建缩放和旋转位图,android,exception,bitmap,Android,Exception,Bitmap,以下代码用于从另一位图bmpSrc创建旋转和缩放位图: final int srcWidth = bmpSrc.getWidth(); final int srcHeight = bmpSrc.getHeight(); final float sx = (float)reqWidth / (float)srcWidth; final float sy = (float
final int srcWidth = bmpSrc.getWidth();
final int srcHeight = bmpSrc.getHeight();
final float sx = (float)reqWidth / (float)srcWidth;
final float sy = (float)reqHeight / (float)srcHeight;
Matrix m = new Matrix();
m.setScale(sx, sy);
final float px = (float) srcWidth / 2;
final float py = (float) srcHeight / 2;
m.setRotate(270, px, py);
bmpFillScreen = Bitmap.createBitmap(bmpSrc, 0, 0, reqHeight, reqWidth, m, true);
但在某些设备(特别是10英寸平板电脑)上,它抛出了这个例外:
java.lang.IllegalArgumentException: x + width must be <= bitmap.width()
at android.graphics.Bitmap.createBitmap(Bitmap.java:554)
java.lang.IllegalArgumentException:x+宽度必须是,位图是否足够大?ie。它可能在12英寸平板电脑或其他高密度像素屏幕平板电脑上都不起作用?您也考虑过使用:createScaledBitmap吗?谢谢,使用更大的bmp解决了这个问题。