Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2694] Android: Camera image orientation doesn't work correctly when image is in tableview

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-10-21T21:24:53.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid, camera, imageview, tableview
ReporterJustin Toth
AssigneeMauro Parra-Miranda
Created2013-10-01T16:37:37.000+0000
Updated2016-03-08T07:41:48.000+0000

Description

When taking a photo with the camera and then rendering it in an imageview within a tableview, the imageview doesn't always render the photo in the correct orientation. To reproduce the issue: Start in portrait, take a picture, and the thumbnail will show up correctly in portrait. Now switch to landscape, take another picture, and the thumbnail will incorrectly show in portrait.
var win, table, row, cameraImage, image;
 
function openCamera() {
    Ti.Media.showCamera({
        success: function(event) {
            if (event.mediaType === Ti.Media.MEDIA_TYPE_PHOTO) {
                if(image) {
                    row.remove(image);
                }
                image = Ti.UI.createImageView({
                    right: '10dp',
                    width: '40dp',
                    height: '40dp',
                    image: event.media,
                    autorotate: true
                });
                row.add(image);
            } else {
                alert('wrong type: ' + event.mediaType);
            }
        },
        cancel: function() {
        },
        error: function(error) {
            alert(error);
        },
        saveToPhotoGallery: true,
        allowEditing: true,
        mediaTypes: [ Ti.Media.MEDIA_TYPE_VIDEO, Ti.Media.MEDIA_TYPE_PHOTO ]
    });
}
 
win = Ti.UI.createWindow({
    backgroundColor: '#fff'
});
 
row = Ti.UI.createTableViewRow({
    height: '60dp',
    className: 'image-row'
});
var cameraImage = Ti.UI.createImageView({
    right: '10dp',
    width: '40dp',
    height: '40dp',
    //image: '/images/camera.png',
    autorotate: true
});
row.add(cameraImage);
 
table = Ti.UI.createTableView({
    top: 0, bottom: 0, left: 0, right: 0
});
table.setData([ row ]);
table.addEventListener('click', openCamera);
win.add(table);
 
win.open();
Tested on Galaxy SIII running Android 4.0.4, but I believe it can be tested on any Android 4.x device.

Comments

  1. Mauro Parra-Miranda 2013-10-21

    Hello, ran the testcase, can't reproduce the issue. Please provide a better testcase or better instructions for reproduce the bug. Best, Mauro

JSON Source