Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25459] iOS: toImage method needs parity with Android & Windows

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-11-10T01:05:07.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.0.0
ComponentsAndroid
LabelsAndroid, toImage
ReporterJorge Macias Garcia
AssigneeHans Knöchel
Created2017-10-30T13:28:08.000+0000
Updated2017-11-15T05:26:33.000+0000

Description

When use toImage method on View we have a discrepance between iOS and the Android / Windows callback parameter Sample: index.js
$.addListener($.index, 'postlayout', function (e) {
  $.box.toImage(function (e) {
        if (OS_IOS) {
            //e is a Event object who has a blob key: e.blob
            $.img.setImage(e.blob);
        } else if (OS_ANDROID || OS_WINDOWS) {
            //e is a Ti.Blob instead a Event object
            //e.blob -> undefined
            $.img.setImage(e);
        }
  });
});

$.index.open();
index.xml
<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/some_sample_image.jpg"/>
    </View>
    <ImageView id="img"/>
  </Window>
</Alloy>

Comments

  1. Hans Knöchel 2017-10-30

    This should be a doc-ticket. No callback should return values directly but inside a dictionary. Please confirm that Android also works with "e.blob", otherwise Android needs an adjustment.
  2. Jorge Macias Garcia 2017-10-30

    No, Android doesn't works with e.blob notation.
  3. Hans Knöchel 2017-10-30

    To be considered for 7.0.0 as it's a breaking change.
  4. Hans Knöchel 2017-11-03

    PR: https://github.com/appcelerator/titanium_mobile/pull/9583 Test-Case:
       var win = Ti.UI.createWindow();
       var view = Ti.UI.createView({backgroundColor: 'green', width: 150, height: 150, top: 100});
       var content = Ti.UI.createView({backgroundColor: 'blue', width: 45, height: 45});
       var imageView = Ti.UI.createImageView({width: 150, height: 150, top: 300});
       view.add(content);
       win.add(view);
       win.addEventListener('postlayout', function() {
       	view.toImage(function(blob) {
       		imageView.setImage(blob);
       	});
       })
       win.add(imageView);
       win.open();
       
  5. Abir Mukherjee 2017-11-09

    FR Passed. PR merged.
  6. Hans Knöchel 2017-11-11

    [~bimmel] This is a breaking change, we should add it to the list of major changes.
  7. (deactived) Brian Immel 2017-11-13

    [~hknoechel], consider it done.
  8. Abir Mukherjee 2017-11-15

    Changes are in SDK 7.0.0.v20171114202841.

JSON Source