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でも正常に動作しますが、Samsung Galaxy S3では、拡大縮小された画像が画面に表示されません。

メソッドにマークを付けてbitmapChange、元のサイズのビットマップを画面に表示させようとしましたが、S3も画面に何も表示されません。

Eclipseの変数の情報はここにあります。ソニーのxperiaの情報はこちらです。

xperiaやその他のデバイスは正常に動作しています。

編集:

LogCatで奇妙なログを取得しました。

写真を撮ると、LogCatに次のメッセージが表示されます。

ここ

私はビデオを決して使いません...

なぜビデオが始まるのですか?

4

1 に答える 1

3

私は周りを検索しましたが、2つの理由が考えられるようです。

1)S3にメモリの問題があります。このSOの質問を確認してくださいS3は、画像をスケーリングする場合でも問題を引き起こします!

解決策-解決策は、ここに示され、このSOの質問で説明されているように、ビットマップ変換をよりメモリフレンドリーにすることです。


2)Samsungの電話は、個々のピクセルを回転させるのではなく、EXIF方向タグを設定します

解決策-このSOの質問を見てください

于 2012-09-04T07:00:53.013 に答える