Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-10994

Android: on OS 3.0 camera picture width/height values are always returned as the picture was in landscape

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Won't Fix
    • Affects Version/s: Release 2.1.2, Release 3.0.0
    • Component/s: Android
    • Labels:
    • Environment:

      TiSDK tested 3.0 CI, 2.1.2 GA, 2.1.1 GA
      Android OS 3.0 (tested on Samsung Tab)

    • Sprint:
      Release 3.0.0

      Description

      Problem description

      Android camera picture height and width values are returned as the picture was always taken in landscape mode (so with size > than height size). This is only reproducible using Android tablets with OS 3.0

      Steps to reproduce

      • Take a picture with the Tablet camera
      • in the 'success:function(event) {..}

        ' get the picture values using event.media.width / event.media.height or event.cropRect.width / event.cropRect.height
        Result: values are always displayed with the width value > than the height value, even if the picture was taken in Portrait.

      var win = Ti.UI.createWindow({
      	backgroundColor : 'black'
      });
       
      var showCamera = function() {
       
      	Titanium.Media.showCamera({
       
      		success : function(event) {
      			Ti.API.info("#### blob width " + event.media.width + "height " + event.media.height);
      			var cropRect = event.cropRect;
       
      			if (cropRect) {
      				Ti.API.info("#### CROP RECT width" + cropRect.width + " height " + cropRect.height);
      			}
       
      			Ti.API.info("#### Displaycaps width" + Titanium.Platform.displayCaps.platformWidth + " height " + Titanium.Platform.displayCaps.platformHeight);
      		},
       
      		cancel : function() {
      		},
       
      		error : function(error) {
      			// create alert
      			var a = Titanium.UI.createAlertDialog({
      				title : 'Camera'
      			});
      			// set message
      			if (error.code == Titanium.Media.NO_CAMERA) {
      				a.setMessage('Please run this test on device');
      			} else {
      				a.setMessage('Unexpected error: ' + error.code);
      			}
      			// show alert
      			a.show();
      			return false;
      		},
      		mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO]
      	});
       
      };
       
      var button = Ti.UI.createButton({
      	title : "show camera",
      	height : 50,
      	width : 200
      });
       
      button.addEventListener("click", function(e) {
      	showCamera();
      });
       
      win.add(button);
       
      win.open();
      

      Additional notes

      On Android 4.1.1 (Nexus Galaxy) it works fine as expected using all SDK versions.
      On Android 2.2.x it works as expected using latest 3.0 CI build (for https://jira.appcelerator.org/browse/TIMOB-3887 bug fix?)
      Note: TIMOB-3887 issue looks fixed and working fine on Android 3.0

      Workaround

      There is a workaround, which onsists in creating an imageView (with 'auto' width and height properties) from the event.image blob from the camera, and take the height/width values from there. In this way, I'm getting the correct height/width values, but this approach would eventually use a lot of device memory converting the blob to image.

      var imageViewSize = Ti.UI.createImageView({
          width : 'auto',
          height : 'auto',
          image : event.media
      }).toImage();
      Ti.API.error("#### imageView width: " +  imageViewSize.width);
      Ti.API.error("#### imageView height: " + imageViewSize.height);
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                ayeung Allen Yeung
                Reporter:
                fcasali Federico Casali
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-14333
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration