Titanium JIRA Archive
Appcelerator Community (AC)

[AC-5323] iOS: toImage doesn't returns a valid Ti.Blob

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionNot Our Bug
Resolution Date2017-10-30T13:21:36.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
LabelsiOS, toImage
ReporterJorge Macias Garcia
AssigneeShak Hossain
Created2017-10-30T09:59:49.000+0000
Updated2017-10-30T13:46:50.000+0000

Description

When try to get a image from a group of views or a simple label toImage method returns a invalid Ti.Blob This works fine on Android returning the right Ti.Blob Sample: index.js
$.addListener($.index, 'open', function(e){
	$.sample.toImage(function(blob){
		$.img.setImage(blob);
	});
});

$.index.open();
index.xml
<Alloy>
  <Window layout="vertical">
    <Label id="sample" text="This is my label" />
    <ImageView id="img" />
  </Window>
</Alloy>
[ERROR] Script Error { [ERROR] column = 27; [ERROR] line = 42; [ERROR] message = "invalid image type"; [ERROR] nativeLocation = "-[TiUIImageView setImage_:] (TiUIImageView.m:751)"; [ERROR] nativeReason = "expected TiBlob, String, TiFile, was: __NSDictionaryM"; !image-2017-10-30-10-58-05-716.png|thumbnail!

Attachments

FileDateSize
image-2017-10-30-10-58-05-716.png2017-10-30T09:58:06.000+000024674

Comments

  1. Mostafizur Rahman 2017-10-30

    Hello [~jormagar], Thanks for sharing with us. Can you please run the command from your command line: *appc info* and send us the output in a text file?
  2. Jorge Macias Garcia 2017-10-30

    Hello, please close this issue. The BLOB is inside the callback param: $.view.toImage(function(e){ $.img.setImage(e.blob); //It works } Please, check the documentation, there is a mistake. The callback param should be a dictionary instead a blob. But on Android we are receiving a blob instead a dictionary. Parity discrepance between IOS - Android. http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.View-method-toImage
  3. Jorge Macias Garcia 2017-10-30

    More info: As you can see in the code, we have a little discrepance.
       $.addListener($.index, 'postlayout', function (e) {
         $.box.toImage(function (e) {
               if (OS_IOS){
                   $.img.image = e.blob;
               } else if (OS_ANDROID) {
                   $.img.setImage(e);
               }
         });
       });
       
       $.index.open();
       
       <Alloy>
         <Window layout="vertical" backgroundColor="white">
           <View id="box" width="Ti.UI.SIZE" height="Ti.UI.SIZE" backgroundColor="pink" layout="vertical" top="25">
             <Label id="sample" text="This is my label" color="red"/>
             <ImageView image="/images/nofoto.jpg"/>
           </View>
           <ImageView id="img"/>
         </Window>
       </Alloy>
       
  4. Hans Knöchel 2017-10-30

    Thanks [~jormagar]. But does it not work on Android when using a dictionary? That'd indeed be a parity issue.
  5. Jorge Macias Garcia 2017-10-30

JSON Source