【发布时间】:2015-11-03 23:46:24
【问题描述】:
由于某种原因,我的位图创建无法正常工作。我发现了一个错误吗?当我尝试使用 Matrix 制作新位图时,它说我的宽度和高度必须大于 0,这是没有意义的。
Bitmap tempbmp = Bitmap.createBitmap(image1, 0, 0, newwidth, newheight, matrix, true);
我知道我似乎没有做过任何研究,我做过,但没有任何意义。我尝试了很多方法,包括将 newwidth 和 newheight 更改为常量,但它仍然不起作用。如果有帮助,这里是堆栈跟踪跟踪
11-03 18:32:00.700: E/AndroidRuntime(9113): java.lang.IllegalArgumentException: width and height must be > 0
11-03 18:32:00.700: E/AndroidRuntime(9113): at android.graphics.Bitmap.createBitmap(Bitmap.java:603)
11-03 18:32:00.700: E/AndroidRuntime(9113): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
11-03 18:32:00.700: E/AndroidRuntime(9113): at com.ajayinkingston.antiverse.Level.tick(Level.java:291)
11-03 18:32:00.700: E/AndroidRuntime(9113): at com.ajayinkingston.antiverse.Logic.tick(Logic.java:65)
11-03 18:32:00.700: E/AndroidRuntime(9113): at com.ajayinkingston.antiverse.GameView.run(GameView.java:142)
11-03 18:32:00.700: E/AndroidRuntime(9113): at java.lang.Thread.run(Thread.java:856)
我正在尝试制作一个旋转门户。我想要一个矩阵平移、旋转和缩放,但我没有得到它的工作。我决定把翻译拿出来,只做一个图像,然后再画图像。矩阵在这里创建:
matrix.reset();
matrix.setScale((newwidth)/image1.getWidth(), (newheight)/image1.getHeight());
matrix.postRotate(rotation, image1.getWidth()/2 + x, image1.getHeight()/2 + y);
newwidth 和 newheight 的值无关紧要,因为常量会发生此错误。
【问题讨论】:
-
那么调用前image1、newwidth、newheight、matrix的值是多少?
-
哦抱歉完全忘记添加将立即添加。
标签: java android matrix bitmap