私はjQueryMobileとPhoneGapを使用して、ユーザーが写真を撮って画面に表示し、サーバーアプリケーションにアップロードして、最終的にWebサイトに投稿できるアプリを作成しています。
これは、横向きモードで写真を撮る場合はうまく機能しますが、ポートレート写真を撮るとアプリケーションがクラッシュします。以下のコードスニペットからわかるように、私は正しいOrientationパラメータを使用して、写真を撮った後に写真の向きを変えようとしています。このパラメータがないと、アプリケーションはクラッシュしませんが、写真が表示されたときに写真の向きが間違っています。
今、私はこれをSonyXPERIAandroidphoneでテストしています。
これが作業を担当するコードです。
function onPhotoFail(message) {
alert('Failed because: ' + message);
}
function onPhotoSuccess(imageURI) {
var $image = $("img#upload-image");
$image.attr("src", imageURI);
}
function capturePhoto() {
navigator.camera.getPicture(onPhotoSuccess, onPhotoFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI , correctOrientation: true });
}
スタックトレースは次のとおりです。
E/AndroidRuntime(31760): FATAL EXCEPTION: main
E/AndroidRuntime(31760): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
E/AndroidRuntime(31760): at android.graphics.Bitmap.nativeCreate(Native Method)
E/AndroidRuntime(31760): at android.graphics.Bitmap.createBitmap(Bitmap.java:477)
E/AndroidRuntime(31760): at android.graphics.Bitmap.createBitmap(Bitmap.java:444)
E/AndroidRuntime(31760): at org.apache.cordova.CameraLauncher.getRotatedBitmap(CameraLauncher.java:483)
E/AndroidRuntime(31760): at org.apache.cordova.CameraLauncher.onActivityResult(CameraLauncher.java:326)
E/AndroidRuntime(31760): at org.apache.cordova.DroidGap.onActivityResult(DroidGap.java:823)
E/AndroidRuntime(31760): at android.app.Activity.dispatchActivityResult(Activity.java:3908)
E/AndroidRuntime(31760): at android.app.ActivityThread.deliverResults(ActivityThread.java:2549)
E/AndroidRuntime(31760): at android.app.ActivityThread.handleSendResult(ActivityThread.java:2595)
E/AndroidRuntime(31760): at android.app.ActivityThread.access$2000(ActivityThread.java:121)
E/AndroidRuntime(31760): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973)
E/AndroidRuntime(31760): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(31760): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(31760): at android.app.ActivityThread.main(ActivityThread.java:3701)
E/AndroidRuntime(31760): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(31760): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(31760): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
E/AndroidRuntime(31760): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
E/AndroidRuntime(31760): at dalvik.system.NativeStart.main(Native Method)
私はいくつかの検索を行いましたが、この正確な問題を抱えている人は誰もいません。どんな助けでも大歓迎です