1

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

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中的变量信息在这里。索尼 xperia 的信息在这里

xperia 和其他设备工作正常。

编辑:

我在 LogCat 中有一些奇怪的日志,

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

这里

我从来不用视频...

为什么视频开始了??

4

1 回答 1

3

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

1) S3 有内存问题。看看这个 SO Question S3 即使在缩放图像时也会出现问题!

解决方案- 解决方案是使位图转换对内存更友好,如此处所示并在SO 问题中讨论


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

解决方案- 看看这个 SO question

于 2012-09-04T07:00:53.013 回答