出于某种原因,我的位图创建无法正常工作。我发现错误了吗?当我尝试使用 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 的值无关紧要,因为常量会发生此错误。
最佳答案
检查Bitmap.java
代码
如果 image1
width
或 height
为 0,则会发生这些异常。
更新。 或矩阵为空。
关于java - 创建位图不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33511286/