Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-28246

Android: Ti.Media.previewImage() fails to display in-memory blobs as of 9.1.0

    Details

    • Story Points:
      3
    • Sprint:
      2020 Sprint 23, 2020 Sprint 24

      Description

      Summary:
      The Ti.Media.previewImage() method fails to display in-memory blobs (ie: blobs not referencing a file) as of Titanium 9.1.0.

      Steps to reproduce:

      1. Build and run the below on Android.
      2. Tap on the "Preview" button. (Will try to display screenshot of app.)
      3. Notice it fails to display image.

      var window = Ti.UI.createWindow();
      var button = Ti.UI.createButton({ title: "Preview" });
      button.addEventListener("click", function(e) {
      	window.toImage(function(imageBlob) {
      		if (!imageBlob) {
      			return;
      		}
      		Ti.Media.previewImage({
      			image: imageBlob,
      			success: function(e) {
      				Ti.API.info("@@@ Successfully displayed preview.");
      			},
      			error: function(e) {
      				Ti.API.error("@@@ Failed to display preview");
      			},
      		});
      	});
      });
      window.add(button);
      window.open();
      

      Work-Around:
      Save the blob to file and preview the file instead.

      var window = Ti.UI.createWindow();
      var button = Ti.UI.createButton({ title: "Preview" });
      button.addEventListener("click", function(e) {
      	window.toImage(function(imageBlob) {
      		if (!imageBlob) {
      			return;
      		}
       
      		// Write the blob to file.
      		var targetFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "image.png");
      		targetFile.write(imageBlob, false);
      		imageBlob = targetFile.read();
       
      		// Preview the above file.
      		Ti.Media.previewImage({
      			image: imageBlob,
      			success: function(e) {
      				Ti.API.info("@@@ Successfully displayed preview.");
      			},
      			error: function(e) {
      				Ti.API.error("@@@ Failed to display preview");
      			},
      		});
      	});
      });
      window.add(button);
      window.open();
      

        Attachments

          Activity

            People

            • Assignee:
              jquick Joshua Quick
              Reporter:
              jquick Joshua Quick
              Reviewer:
              Gary Mathews
              Tester:
              Satyam Sekhri
            • Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Integration