强制关闭位图超过32位

时间:2013-07-17 15:35:26

标签: android bitmap

首先即时制作迷你2的应用程序并且运行得很完美,但是当我尝试在我的奇迹中为什么我有一半的屏幕?时,我得到宽度奇迹的价值是420?

WindowManager wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE); // the results will be higher than using the activity context object or the getWindowManager() shortcut
      wm.getDefaultDisplay().getMetrics(displayMetrics);
wm.getDefaultDisplay().getMetrics(displayMetrics);
          lebar = displayMetrics.widthPixels; 

当我尝试使用lebar = (int) displayMetrics.widthPixels * displayMetrics.densityDpi;

我强行关闭

07-17 22:28:26.994: E/AndroidRuntime(3936): FATAL EXCEPTION: main
07-17 22:28:26.994: E/AndroidRuntime(3936): java.lang.IllegalArgumentException: bitmap size exceeds 32bits
07-17 22:28:26.994: E/AndroidRuntime(3936):     at android.graphics.Bitmap.nativeCreate(Native Method)
07-17 22:28:26.994: E/AndroidRuntime(3936):     at android.graphics.Bitmap.createBitmap(Bitmap.java:691)
07-17 22:28:26.994: E/AndroidRuntime(3936):     at android.graphics.Bitmap.createBitmap(Bitmap.java:668)
07-17 22:28:26.994: E/AndroidRuntime(3936):     at android.graphics.Bitmap.createBitmap(Bitmap.java:601)
07-17 22:28:26.994: E/AndroidRuntime(3936):     at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:481)
07-17 22:28:26.994: E/AndroidRuntime(3936):     at skripsi.slidame.slidameBoard.<init>(slidameBoard.java:84)

main.java

 private final void createGameBoard(Bitmap gambar) {
          board.once=true;
          tableLayout = (TableLayout) findViewById(R.id.TableLayout1);    
          tableLayout.removeAllViews();
          board = slidameBoard.createGameBoard(this, 
                gambar, 
                tableLayout,
                lebar,
                lebar,
                ukurangrid);
         board.setNumbersVisible(numbersVisible);
         gambar.recycle(); 
       }

second.java

public static slidameBoard createGameBoard(Context context, 
                                 Bitmap bitmap, 
                                 TableLayout parentLayout,
                                 int width,
                                 int height,
                                 int gridSize) {

      board = new slidameBoard(context, 
                       bitmap, 
                       parentLayout, 
                       width, 
                       height, 
                       gridSize);

      return board;
   }

0 个答案:

没有答案