IllegalArgumentException in Bitmap.getPixels()

安稳与你 提交于 2019-12-04 07:48:47
Haphazard

You have your width and hight switched.

myBitmap.getPixels(pixels, 0, myBitmap.getWidth(), 0, 0, myBitmap.getHeight(), myBitmap.getWidth());

vs

public void getPixels (int[] pixels, int offset, int stride, int x, int y, int width, int height) http://developer.android.com/reference/android/graphics/Bitmap.html#getPixels(int[], int, int, int, int, int, int)

I think there's a typo in this code. Try this:

myBitmap.getPixels(pixels, 0, myBitmap.getWidth(), 0, 0,
   myBitmap.getWidth(), myBitmap.getHeight());
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!