Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android.graphics.Bitmap.checkPixelsAccess错误_Java_Android - Fatal编程技术网

Java Android.graphics.Bitmap.checkPixelsAccess错误

Java Android.graphics.Bitmap.checkPixelsAccess错误,java,android,Java,Android,我看到这个错误通过flurry报告,但不知道它与什么有关,也不知道如何在我的Android代码中找到错误所在 class java.lang.IllegalArgumentException Msg: android.graphics.Bitmap.checkPixelsAccess:823 (x + width must be <= bitmap.width()) class java.lang.IllegalArgumentException Msg:android.graphics

我看到这个错误通过flurry报告,但不知道它与什么有关,也不知道如何在我的Android代码中找到错误所在

class java.lang.IllegalArgumentException
Msg: android.graphics.Bitmap.checkPixelsAccess:823 (x + width must be <= bitmap.width())
class java.lang.IllegalArgumentException

Msg:android.graphics.Bitmap.checkPixelsAccess:823(x+宽度必须您的代码必须包含以前对方法的调用:

yourBitmap.getPixels(像素、偏移量、步幅、x、y、宽度、高度);

引发异常的原因是:

起始x坐标+要从当前行获取的量超过源位图宽度

以下图片可以更好地解释这种情况:

希望这有帮助。
注意。

您的代码之前必须包含对该方法的调用:

yourBitmap.getPixels(像素、偏移量、步幅、x、y、宽度、高度);

引发异常的原因是:

起始x坐标+要从当前行获取的量超过源位图宽度

以下图片可以更好地解释这种情况:

希望这有帮助。 注意。

//编码方法
位图encodeAsBitmap(字符串str)引发WriterException{
int black=0xFF000000;
int白色=0xFFFFFF;
整数宽度=400;
内部高度=400;
位矩阵结果;
位图=空;
试一试{
结果=新的多格式编写器()。编码(str,
条形码格式。QR_码,高度,宽度,空);
int w=result.getWidth();
int h=result.getHeight();
int[]像素=新的int[w*h];
对于(int y=0;y
//编码方法
位图encodeAsBitmap(字符串str)引发WriterException{
int black=0xFF000000;
int白色=0xFFFFFF;
整数宽度=400;
内部高度=400;
位矩阵结果;
位图=空;
试一试{
结果=新的多格式编写器()。编码(str,
条形码格式。QR_码,高度,宽度,空);
int w=result.getWidth();
int h=result.getHeight();
int[]像素=新的int[w*h];
对于(int y=0;y
        //encoding method
        Bitmap encodeAsBitmap(String str) throws WriterException {
         int black = 0xFF000000;
         int white = 0xFFFFFFFF;

         int width=400;
         int height=400;

            BitMatrix result;
            Bitmap bitmap=null;
            try {
                result = new MultiFormatWriter().encode(str,
                        BarcodeFormat.QR_CODE,height ,width , null);

                int w = result.getWidth();
                int h = result.getHeight();
                int[] pixels = new int[w * h];
                for (int y = 0; y < h; y++) {
                    int offset = y * w;
                    for (int x = 0; x < w; x++) {
                        pixels[offset + x] = result.get(x, y) ? black : white;
                    }
                }
                bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
//Use the same value of the height and width respectively    
                bitmap.setPixels(pixels, 0, 400, 0, 0, 400, 400);
            } catch (Exception iae) {
                iae.printStackTrace();
                return null;
            }
            return bitmap;
        }