[TIMOB-25280] Windows: Allow view.toImage to work on elements not in the XAML visual tree
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | Medium |
| Status | Closed |
| Resolution | Won't Do |
| Resolution Date | 2021-02-11T12:14:40.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Windows |
| Labels | n/a |
| Reporter | Ewan Harris |
| Assignee | Unknown |
| Created | 2017-09-14T14:11:40.000+0000 |
| Updated | 2021-02-11T12:14:40.000+0000 |
Description
Description
Currently the .toImage method for views will only work if the view is in the XAML visual tree, that is to say added to another view/window. I believe this is a limitation of the API used [rendertargetbitmap](https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.media.imaging.rendertargetbitmap), I think it might be possible to use [XamlRenderingBackgroundTask](https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Media.Imaging.XamlRenderingBackgroundTask) see https://stackoverflow.com/questions/29262195/rendertargetbitmap-without-putting-it-on-ui
var win = Ti.UI.createWindow();
var view = Ti.UI.createView({
backgroundColor: 'red',
width: 400,
height: 400,
borderRadius: 200
});
// win.add(view);
view.toImage(function (image) {
console.log('image done');
console.log(image.length)
});
win.open();
No comments