首页 文章

创建位图无效

提问于
浏览
1

由于某种原因,我的位图创建无效 . 我发现了一个错误吗?当我尝试使用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)

我正在努力 Build 一个旋转门户网站 . 我希望有一个矩阵翻译,旋转和缩放,但我没有得到那个工作 . 我决定取出翻译并制作图像,然后绘制图像 . 矩阵在这里创建:

matrix.reset();             
matrix.setScale((newwidth)/image1.getWidth(), (newheight)/image1.getHeight());
matrix.postRotate(rotation, image1.getWidth()/2 + x, image1.getHeight()/2 + y);

newwidth和newheight的值无关紧要,因为常量会发生此错误 .

2 回答

相关问题