February 19, 2013

epicfailguy93 epicfailguy93
Lab Rat
27 posts

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

3 replies

February 19, 2013

Jens Jens
Hobby Entomologist
365 posts

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?

February 19, 2013

epicfailguy93 epicfailguy93
Lab Rat
27 posts
Jens wrote:
Perhaps you should rather make a separate window of your scene and grab that instead?
epicfailguy93 wrote:
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.

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?

February 20, 2013

capisce capisce
Lab Rat
32 posts

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).

 
  ‹‹ Custom C++ types and QJSEngine      Updating fontSize via function key call - calling functions in QML ››

You must log in to post a reply. Not a member yet? Register here!