【问题标题】:Bitmap issue in Samsung Galaxy S3三星 Galaxy S3 中的位图问题
【发布时间】:2012-08-28 16:36:38
【问题描述】:

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

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

我从不使用视频...

为什么要播放视频??

【问题讨论】:

  • 不要关注我必须缩放位图的原因,这是一个我不想说的复杂故事。让我们关注一下为什么S3不能在ImageView上显示图片,mHight和mWidth在S3和xperia中也是-1,但是为什么xperia可以正常工作,即使是另一个设备……,只是S3失败了

标签: android


【解决方案1】:

我搜索了一下,似乎有两个可能的原因:

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

解决方案- 解决方案是使位图转换更内存友好,如herethis SO question 中讨论的那样


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

解决方案-看看this SO question

【讨论】:

  • 在我的情况下,Samsung Galaxy Nexsus 工作正常...只是 S3 无法显示图像,我在 LogCat 中发现了一些奇怪的消息,有人知道为什么在我想要的时候触发了视频功能拍照?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-29
  • 1970-01-01
  • 2015-02-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多