Details
-
Type:
Bug
-
Status: Closed
-
Priority:
High
-
Resolution: Unresolved
-
Affects Version/s: Release 9.1.0
-
Fix Version/s: Release 9.3.0
-
Component/s: Android
-
Labels:
-
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:
- Build and run the below on Android.
- Tap on the "Preview" button. (Will try to display screenshot of app.)
- 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();
|