Save single Item as image



  • I need a way to save Item's texture as a png file. I was trying to understand, but it was not easy. You can simply save the contents of the entire window, not a separate Item. I tried to make a transparent window background and display a single item necessary to me. In this case when you save the image, background turns black.

    I also tried:
    layer.format: ShaderEffectSource.Alpha - nothing has changed
    get the texture from QQuickItem::textureProvider()::texture() - textureProvider() always returns 0



  • Why do you want to save the texture of a QQuickItem in the first place? Unlike with QWidgets, there is no way to "grab" the contents of a scene graph for a specific item. Getting the texture will just return the original image without shader effects or child items applied so you might as well just use the original image source you set on the Image. Perhaps you should rather make a separate window of your scene and grab that instead?



  • [quote author="Jens" date="1361265251"]Perhaps you should rather make a separate window of your scene and grab that instead?[/quote]

    [quote author="epicfailguy93" date="1361229673"]I tried to make a transparent window background and display a single item necessary to me. In this case when you save the image, background turns black.[/quote]

    Previously, I used the text overlaid shader to glow, but for better performance, I decided to replace all the text on the image. Such a soft glow can not be obtained using Photoshop, so I decided to find a way to save the contents of the ShaderEffectItem. So, is it possible?



  • bq. get the texture from QQuickItem::textureProvider()::texture() – textureProvider() always returns 0

    Did you do "layer.enabled: true" on the item on the QML side? Otherwise as you note it won't have a texture.

    Make sure to only access the texture from the scene graph thread though, by connecting with a DirectConnection to QQuickView::afterRendering() (defined in QQuickWindow).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.