Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16508] Android: Image doesn't show after taking photo with camera

GitHub Issuen/a
TypeStory
PriorityLow
StatusClosed
ResolutionWon't Fix
Resolution Date2014-04-12T02:45:01.000+0000
Affected Version/sRelease 3.3.0
Fix Version/s2014 Sprint 07, 2014 Sprint 07 SDK
ComponentsAndroid
Labelsn/a
ReporterHieu Pham
AssigneeHieu Pham
Created2014-02-26T00:13:41.000+0000
Updated2017-03-24T00:03:10.000+0000

Description

After taking photo using camera, the image doesn't show up when bitmap is added to imageView. Log shows this error: "bitmap too large to be uploaded into a texture".
var win1 = Titanium.UI.createWindow({
    backgroundColor : '#fff',
});
 
var contenner = Ti.UI.createView({
    width : Ti.UI.SIZE,
    height : Ti.UI.SIZE,
    top : 0,
    backgroundColor : '#eee',
    borderColor : '#eee',
    layout : 'vertical',
});
win1.add(contenner);
 
var anImageView = Ti.UI.createImageView({
    autorotate: true,
});
contenner.add(anImageView);
 
var controlview = Ti.UI.createView({
    width : Ti.UI.FILL,
    height : Ti.UI.SIZE,
    top : 20,
});
 
contenner.add(controlview);
 
var frmcamera = Ti.UI.createButton({
    backgroundImage : 'none',
    backgroundColor : '#ff0000',
    title : 'Open Camera',
    color : '#fff',
    width : 80,
    height : 50,
    left : 10,
});
 
frmcamera.addEventListener('click', function() {
    fireUpTheCamera();
});
 
controlview.add(frmcamera);
 
var overlay = Ti.UI.createView({
    width : Ti.UI.FILL,
    height : Ti.UI.FILL,
    autorotate: true,
}); 
// Create an ImageView.
var overlayImg = Ti.UI.createImageView({
    image : '/KS_nav_ui.png',
    width : Ti.UI.SIZE,
    height : Ti.UI.SIZE,
});
 
 
overlayImg.addEventListener('click', function() {
    Ti.Media.takePicture();
});
overlay.add(overlayImg);
 
function fireUpTheCamera() {
    Titanium.Media.showCamera({
 
        success : function(event) {
            var cropRect = event.cropRect;
            var image = event.media;
 
            Ti.API.debug('Our type was: ' + event.mediaType);
            if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
                anImageView.image = image;
                //new_upload_profile_picture_update(anImageView.image);
            } else {
                alert("got the wrong type back =" + event.mediaType);
            }
        },
        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();
        },
        saveToPhotoGallery : true,
        allowEditing : false,
        overlay : overlay,
        mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO]
    });
}
 
win1.open();

Comments

  1. Hieu Pham 2014-02-26

    master PR: https://github.com/appcelerator/titanium_mobile/pull/5385
  2. Vishal Duggal 2014-04-12

    Going to mark this as Wont Fix
  3. Vishal Duggal 2014-04-12

    The results from a camera callback have a blob which can give you image dimensions. Take a 1024x1024 image for example. If you load this large a bitmap into memory it is going to take at best 2MB(RGB565) or at worst 4MB(ARGB888) of memory. You really shouldn't be loading that much data. Newer devices of course produce images with much higher resolution. Ti.Blob has methods to resize and load smaller images into memory. Developers should use that instead.
  4. Lee Morris 2017-03-22

    Closing ticket as "Won't Fix".

JSON Source