FATAL SIGNAL 11关于位图创建错误

时间:2014-03-18 06:15:41

标签: java android bitmap

在我的代码中,我首先从native进行调用,在java中创建一个位图(大小:800 x 480)。此调用由回调函数递归进行,位图由此函数创建:

public void createBitmap(byte[] buffer, int width, int height)  
{
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
bitmap.copyPixelsFromBuffer(ByteBuffer.wrap(buffer));  
}

然后,另一个本机函数调用一个java函数,该函数需要选择原始位图的一个区域并创建一个新的位图。这是通过以下功能完成的。它选择以前由上面的函数创建的位图并获取它的一部分(x,y坐标),然后创建一个新的位图:

public Bitmap getResizedBitmap(int x, int y, int newWidth, int newHeight) {
    if (bitmap != null) {
        AppLogger.LOGE("check : 1");
        AppLogger.LOGE("check : x" + bitmap.getWidth() + " Y : " + bitmap.getHeight());

        bm = Bitmap.createBitmap(bitmap, x, y, 10, 1);

        AppLogger.LOGE("check : 2");

        int width = bm.getWidth();
        int height = bm.getHeight();

        float scaleWidth = ((float) newWidth) / width;
        float scaleHeight = ((float) newHeight) / height;

        // CREATE A MATRIX FOR THE MANIPULATION
        Matrix matrix = new Matrix();
        // RESIZE THE BIT MAP
        matrix.postScale(scaleWidth, scaleHeight);
        // "RECREATE" THE NEW BITMAP
        Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);

        AppLogger.LOGE("check : 3");

        return bm;

    } else {
        AppLogger.LOGE("check : 4");
        bm = Bitmap.createBitmap(newWidth, newHeight, android.graphics.Bitmap.Config.ARGB_8888);
        return bm;
    }
}
然而,我已经开始从空间错误中解脱出来(至少这是我从类似问题的广泛搜索中所想到的)。错误发生在第一个bitmap.create,我得到原始图像的一部分。我是怎么做到的? p.s - 位图创建在循环上,即多次完成。 错误:Libc致命信号11

0 个答案:

没有答案