4

We're using EGLFS to run a QML app on an embedded linux device without a X server. So I can't use the usual techniques for getting a screenshot (e.g. using a screenshot utility app). In this question I found the technique of using QQuickView::grabWindow().

My question: Is the result of this function guaranteed to be pixel-perfect identical to what the user sees on the screen? I'm worried that to grab the window contents, Qt might have to rerender the window using a different code path (e.g. render-to-texture), which may cause results to differ.

I'd like a reliable reference included in your answers, too.

Community
  • 1
  • 1
Stefan Monov
  • 11,332
  • 10
  • 63
  • 120
  • Are you asking how to be sure that "colors in your application" match what the user sees on the screen? Because there's a *huuuuuge* amount of literature in that regard... – peppe Nov 07 '16 at 17:02
  • @peppe: No. When I call `grabWindow`, I want the pixel data I get to be identical to the pixel data in the window, the same data which is presented to the user. I.e. not a separately rendered, "pretty close" representation of what is in the window. – Stefan Monov Nov 07 '16 at 17:08

1 Answers1

3

As far as I can tell, the screenshot is not going to be identical. Follow the code from QQuickWindow::grabWindow: it ends up calling qt_gl_read_framebuffer, which is always going to read the image out as RGB(A)8. Your actual framebuffer might be different (for instance, it could be RGB565).

(I also seem to remember that one cannot use RGBA reading via glReadPixels out of a RGB565 framebuffer, but I am not 100% sure that's true in all OpenGL versions/variants...)

Depending on your drivers, a workaround could be reading /dev/fb0 contents. Anyhow, please file a bug report if you need this functionality.

peppe
  • 21,934
  • 4
  • 55
  • 70
  • Yes it depends on what the Stefan means as 'pixel perfect', in my case we get lossless PNGs and as far as the untrained eye perceives it's 'pixel perfect'. – Ariel M. Jun 29 '18 at 14:59