由於某種原因,我的位圖創建不起作用。我發現了一個錯誤?當我嘗試使用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的值是多少? –
哦,對不起,完全忘記添加會立即添加。 – Ajay