createBitmap中的IllegalArgumentException。 Android的

时间:2017-05-29 12:31:55

标签: android bitmap

我试图创建一个Bitmap,但由于某种原因,onDraw方法中的这条指令会抛出IllegalArgumentException

Bitmap resizedBitmap = Bitmap.createBitmap(map,0,0,map.getWidth(),map.getHeigth(),matrix,true);

以前正确定义了地图

Bitmap map = BitmapFactory.decodeResource(this.getContext().getResources(), R.drawable.map);

map.getWidth()和map.getHeigth()返回3072(在createBitmap(...)之前检查) 矩阵:

Matrix matrix = new Matrix();
matrix.postScale(0.0625f, 0.0625f);`

错误如下:

                             --------- beginning of crash
05-29 14:27:21.471 30685-31044/com.example.project E/AndroidRuntime: FATAL EXCEPTION: Thread-2416
    Process: com.example.project, PID: 30685
    java.lang.IllegalArgumentException: width and height must be > 0
            at android.graphics.Bitmap.createBitmap(Bitmap.java:829)
                at android.graphics.Bitmap.createBitmap(Bitmap.java:808)
                at android.graphics.Bitmap.createBitmap(Bitmap.java:739)
                at com.example.project.VistaMultitactil.onDraw(VistaMultitactil.java:236)
                at com.example.project.ThreadMultitactil.run(ThreadMultitactil.java:31)

我不理解它,因为宽度和高度都是3072

0 个答案:

没有答案