Sunday, March 2, 2014

FC Error: java.lang.IllegalArgumentException: x + width must be <= bitmap.width ()


When you call Force Quit Application Screenshot:
 
public Bitmap takeScreenShot (Activity activity) {
/ / View is that you need screenshot View
View view = activity.getWindow () getDecorView ();.
view.setDrawingCacheEnabled (true);
view.buildDrawingCache ();
b1 = view.getDrawingCache ();

/ / Get the status bar height
Rect frame = new Rect ();
activity.getWindow () getDecorView () getWindowVisibleDisplayFrame (frame);..
int statusBarHeight = frame.top;
/ / Get the screen length and height
.. int width = activity.getWindowManager () getDefaultDisplay () getWidth ();
/ / Remove the title bar
b = Bitmap.createBitmap (b1, 0, statusBarHeight, width, b1.getHeight ()-statusBarHeight);
view.destroyDrawingCache ();
return b;
}

Have to know how to avoid this problem it?<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
x + width must be <= bitmap.width () exceeds the width of the chart you want to cut the width of ~ width changed b1.getWidth () try ~
Reply:
bitmap1.getPixel (i, j)
Reply:
Submitted late, the last did not finish,
From the position (0,0) to take, a width and height should be less
bitmap1.getPixel (bitmap2.getWidth () -1, bitmap1.getHeight () -1);

No comments:

Post a Comment