Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25527] ANDROID - Camera picture blob ImageView toImage

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterJohnson Joseph
AssigneeYordan Banev
Created2017-11-17T12:40:44.000+0000
Updated2017-11-30T15:27:19.000+0000

Description

The Sample Code is here: https://www.dropbox.com/s/j0duneeypnzk3z8/AndroidPictureToImageBug.zip?dl=0 In Android, using Titanium 6.3.0, I cannot toImage an ImageView with an image blob set. I was able to do this in versions prior to 6.3.0. I have attached the sample code. The end result of the code should be a watermarked camera image. When the toImage() result of the below function is set to the image attribute of an ImageView on the index.xml, the appear appears white or gray with a distorted Label. function getViewWithLogoOverlay_Android(imgCompressedBlob) { //create image with EZSmiles logo var imgView = Ti.UI.createImageView(); imgView.width = Ti.UI.FILL; imgView.height = Ti.UI.FILL; imgView.image = imgCompressedBlob; imgView.defaultImage = imgCompressedBlob; imgView.backgroundColor = 'transparent'; imgView.addEventListener("load", function() { console.log("helllooooo HELLLOOOOO"); }); var imgLogo1 = Ti.UI.createLabel(); imgLogo1.color = "#e2e2e2"; imgLogo1.opacity = .5; imgLogo1.text = "Powered By"; imgLogo1.font = { fontFamily: 'Nunito-Regular', fontSize: 12 }; var imgLogo = Ti.UI.createLabel(); imgLogo.color = "#e2e2e2"; imgLogo.opacity = .5; imgLogo.text = "EZSmiles"; imgLogo.font = { fontFamily: 'Nunito-Regular', fontSize: 24 }; var imgViewColl = Ti.UI.createView(); imgViewColl.width = Ti.UI.SIZE; imgViewColl.height = Ti.UI.SIZE; imgViewColl.layout = "vertical"; imgViewColl.left = "10%"; imgViewColl.top = "75%"; imgViewColl.add(imgLogo1); imgViewColl.add(imgLogo); var templateView = Ti.UI.createView(); templateView.width = "100%"; templateView.height = "100%"; templateView.add(imgView); templateView.add(imgViewColl); return templateView.toImage(); }

Comments

  1. Yordan Banev 2017-11-21

    [~jjoseph] Hello! Have you had any trouble with the same code on iOS after switching SDK versions ?
  2. Johnson Joseph 2017-11-21

    No, I don't. It works properly in iOS in 6.3.0
  3. Yordan Banev 2017-11-22

    [~jjoseph] Recent changes for layout handling (in 6.2.0) have caused that. It is a conflict between the templateView and ImgView dimensions - both have relative values and templateView does not have a parent to use as a base. Workaround for that would be to set the dimensions of imgView to:
       var imgView = Ti.UI.createImageView();
       imgView.width = Ti.UI.SIZE;
       imgView.height = Ti.UI.SIZE;
       
    so they are based on the content of the image source. Let me know if that works out for you.
  4. Johnson Joseph 2017-11-22

    This worked! Thank you for the quick response on this. Very much appreciated.

JSON Source