1

How could I translate the QML scene(like Rectangle, Image etc) into a texture and save it? Anyone tried this before?If I can translate the components to texture, then I should be able to save the image after processing by particle systems or shaderEffects

Example:

Rectangle{
  id:root

  widht:640
  height: 480

  ToTexture{ id: toTexture} //a new type created by c++

  MouseArea{

     anchors.fill: parent

     onClicked: {         
         toTexture.saveAsTexture(root)
     }
  }
}

The problem is, how could I design a new type like ToTexture? The example of " Scene Graph - OpenGL Under QML." show us how to render a qml scene, but I can't find an example show us how to transfer the qml scene to a texture.

Without this function, I can't save the graph generated QtQuick

StereoMatching
  • 4,971
  • 6
  • 38
  • 70
  • With "the QML scene" do you literally mean an entire QML scene? In QtQuick2 that's trivial with QQuickWindow::setRenderTarget, and I pretty much guess it's the same in QQ1 by QDeclarativeView::render onto a QImage... – peppe Jun 13 '13 at 07:07
  • Precisely, I want to do what shaderEffectSource do, render Rectangle, Image and other components to texture and get the pointer of those texture, save the texture by QImage. – StereoMatching Jun 13 '13 at 09:48
  • Any example? I found one called OpenGL Under QML,show us how to render the qml scene, but there are no example show us how to translate the qml scene into a texture and save it.In QtQuick2, we can't even simply transfer the Image to QImage and save it like QQ1 did. – StereoMatching Jun 13 '13 at 09:54
  • 1
    http://stackoverflow.com/questions/16792634/how-to-printwith-the-printer-a-qml-object/16793242#16793242 – dtech Jun 13 '13 at 16:18
  • Thanks, ddriver, do you know how to extract the the raw framebuffer data of the visible qml component now?I would like to record the scene as video, but can't find a way to do so, grabWindow() is too slow for video – StereoMatching Jun 14 '13 at 06:27

1 Answers1

0

I found another solution, on this post

take screenshot

We could take the screenshot of the qml scene, then we could do anything to it, include render it to texture

Community
  • 1
  • 1
StereoMatching
  • 4,971
  • 6
  • 38
  • 70