Android创建缩放和旋转的位图

时间:2015-01-08 15:37:34

标签: 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)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)

我该怎么做才能解决这个问题?

0 个答案:

没有答案
相关问题