三星Galaxy S3中的位图问题

时间:2012-09-04 03:19:09

标签: android

我写了一个方法来改变相机拍摄的位图:

public Bitmap bitmapChange(Bitmap bm) {
    /* get original image size */
    int w = bm.getWidth();
    int h = bm.getHeight();

    /* check the image's orientation */
    float scale = w / h;

    if(scale < 1) { 

        /* if the orientation is portrait then scaled and show on the screen*/
        float scaleWidth = (float) 90 / (float) w;
        float scaleHeight = (float) 130 / (float) h;
        Matrix mtx = new Matrix();
        mtx.postScale(scaleWidth, scaleHeight);
        Bitmap rotatedBMP = Bitmap.createBitmap(bm, 0, 0, w, h, mtx, true);
        return rotatedBMP;

    } else {

        /* if the orientation is landscape then rotate 90 */
        float scaleWidth = (float) 130 / (float) w;
        float scaleHeight = (float) 90 / (float) h;
        Matrix mtx = new Matrix();
        mtx.postScale(scaleWidth, scaleHeight);
        mtx.postRotate(90);
        Bitmap rotatedBMP = Bitmap.createBitmap(bm, 0, 0, w, h, mtx, true);
        return rotatedBMP;
    }
}

在其他Android设备上工作正常,即使是Galaxy Nexus,但在三星Galaxy S3中,缩放后的图像也不会在屏幕上显示。

我尝试标记bitmapChange方法,让它在屏幕上显示原始大小的位图,但S3也不会在屏幕上显示任何内容。

eclipse中变量的信息是here。 索尼xperia的信息是here

xperia和其他设备工作正常。

编辑:

我在LogCat中得到了一些奇怪的日志,

当我拍照时,LogCat会显示一些消息:

here

我从不使用视频...

视频开始的原因??

1 个答案:

答案 0 :(得分:3)

我四处寻找,似乎有两个可能的原因:

1)S3有内存问题。查看this SO Question即使缩放图像,S3也会出现问题!

解决方案解决方法是使位图转换更加内存友好,如here所示,并在this SO question中讨论


2)三星手机设置EXIF方向标签,而不是旋转单个像素

解决方案:查看this SO question