Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25280] Windows: Allow view.toImage to work on elements not in the XAML visual tree

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionWon't Do
Resolution Date2021-02-11T12:14:40.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsWindows
Labelsn/a
ReporterEwan Harris
AssigneeUnknown
Created2017-09-14T14:11:40.000+0000
Updated2021-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();

Comments

No comments

JSON Source