I need to grab the screen or window in QNX 6.5.0 - 8 times per second. If use standart low-level API function PgReadScreen(), for resolution screen 1920x1080 (24 bit) its very slooow... When create context PdCreateDirectContext(), the driver blocks all other painting. It freezes the screen for a few seconds.
I also looked at the regions, but as I understood, they do not contain graphic data of windows?
Used Qt 5.7.1 with reduced functionality. For example, the function grabWindow() not implemented.
Good idea: use the widget's render() function, but some objects... for example: list of comboBox is widget too. I have to follow and draw it too.
Any ideas?
Window-grabbing is really simple. A top-level QWidget (widget.isWindow()==true) is backed by a QImage backing store. Grabbing this requires no repainting or OS API calls. This answer has a working, mostly complete yet simple implementation of this idea. It should be portable to any platform and any widget as long as the raster backend is used.
Related
When I browsed the source code of Qt I didn't find how it actually draws a GUI component, but I know it uses OpenGL.
I want to know how does a GUI library like Qt draw its GUI components (ex : QPushButton ,QWidget)?
Can any one help me with a basic idea ?
In Qt-project site :
Qt is painting QtWidgets using QPainter, which uses (usually) the raster engine to draw the content. It is not using native OS calls, apart from few exceptions (file dialog, for example, which can be drawn either natively or using QtWidgets).
QtQuick is painted using scenegraph, so OpenGL. Also, no native OS calls here.
I think you either misunderstood (there are several meanings of the word “native” in computing) the stackoverflow post, or your information source is wrong.
OK, then to be clear: by “native” I’ve meant using native OS controlls, like wxWidgets library does: asking the OS to draw native scroll bar, or combo box, etc. Qt does not do this. It paints all the widgets itself, and only tries to mimick the looks of the OS it is running on.
But obviously, some kind of native OS calling is happening deep inside, in order to actually draw some pixels on the screen, and open native window container. But that is usually not important at all to high level UI developers.
You have a clear choice whether the widget should be drawn by the CPU or the GPU: widgets can use different painting methods (native, raster, OpenGL, for more see here! [qt-project.org]), and the user has choice which one should be utilised. Most people do not use that, though, because the default settings work well.
Thanks.
So I found this intresting file (ref to it I found in here). It is sad
Also chech out glGrab which uses OpenGL to grab the screen and is very fast.
so I wonder can we grab desctop screen frames via openGl on Windows and Linux using some openGL wrapper like SDL?
OpenGL can (easily, fast, and in a straightforward way) grab the front/back buffers that it owns and that you have a valid context for.
In other words: no.
The desktop is not owned by OpenGL. Under Windows, it is managed by the driver under pre-Vista, and by the window manager under Vista/7. You'll need the BitBlt function here, which is neither portable, nor fast.
Under Linux, the desktop may at least sometimes indeed be owned by OpenGL (compositing window managers), but you don't have a context handle for that.
If you can lessen your requirements from "Desktop" to "my window's content", then it all becomes super easy. In the simplest case, it's one function call, and if you want to do it asynchronously with DMA, it's 3-4 more.
I'm trying to figure out how to create a graphical interface, in X11, which exists outside of a window manager's/desktop environment's standard window frame. For example, when Thunderbird finds new mail, it shows a special alert in the lower right hand corner of the screen which is shown without any frame (no close/minimize buttons, etc.).
I'm specifically interested in doing this in QT with C++, but if someone knows a solution with a different graphical library, that would be helpful too.
For QT pass Qt::FramelessWindowHint as a window flag when you construct your top level widget.
See here for more info:
http://doc.qt.nokia.com/main-snapshot/qt.html#WindowType-enum
You can do this with X as well although I haven't done so in a long time.
http://www.xfree86.org/current/XCreateWindow.3.html
With GTK you would use gtk_window_set_decorated(), which would probably be Gtk::Widget->set_decorated() (I think, I don't use gtkmm).
http://developer.gnome.org/gtkmm/unstable/classGtk_1_1Window.html#a67adb1d8051a38e0e5272f141bb8778c
I've seen things like this and I was wondering if this was possible, say I run my application
and it will show the render on whatever is below it.
So basically, rendering on the screen without a window.
Possible or a lie?
Note: Want to do this on windows and in c++.
It is possible to use your application to draw on other application's windows. Once you have found the window you want, you have it's HWND, you can then use it just like it was your own window for the purposes of drawing. But since that window doesn't know you have done this, it will probably mess up whatever you have drawn on it when it tries to redraw itself.
There are some very complicated ways of getting around this, some of them involve using windows "hooks" to intercept drawing messages to that window so you know when it has redrawn so that you can do your redrawing as well.
Another option is to use clipping regions on a window. This can allow you to give your window an unusual shape, and have everything behind it still look correct.
There are also ways to take over drawing of the desktop background window, and you can actually run an application that draws animations and stuff on the desktop background (while the desktop is still usable). At least, this was possible up through XP, not sure if it has changed in Vista/Win7.
Unfortunately, all of these options are too very complex to go in depth without more information on what you are trying to do.
You can use GetDesktopWindow(), to get the HWND of the desktop. But as a previous answer says (SoapBox), be careful, you may mess up the desktop because the OS expects that it owns it.
I wrote an open source project a few years ago to achieve this on the desktop background. It's called Uberdash. If you follow the window hierarchy, the desktop is just a window in a sort of "background" container. Then there is a main container and a front container. The front container is how windows become full screen or "always on top." You may be able to use Aero composition to render a window with alpha in the front container, but you will need to pass events on to the lower windows. It won't be pretty.
Also, there's a technology in some video cards called overlays/underlays. You used to be able to render directly to an overlay. Your GPU would apply it directly, with no interference to main memory. So even if you took a screen capture, your overlay/underlay would not show up in the screen cap. Unfortunately MS banned that technology in Vista...
I'm looking for some API for printing.
Basically what I want to achieve is to print set of pixels(monochromatic bitmap which I store in memory) onto the generic paper format (A4,A5..etc.).
What I think that would be minimum API is:
printer devices list
printer buffer where I could send my in-memory pixmap (ex. like winXP printer tasks folder)
some API which would translate SI dimensions onto printer resolution, or according to previous - in memory pixmap (ex. 450x250) onto paper in appropriate resolution.
What I was considering is postScript, but I've some old LPT drived laserjet which probably doesn't support *PS.
Currently I'm trying to find something interesting in Qt - QGraphicsView.
http://doc.trolltech.com/4.2/qgraphicsview.html
Well you got close, look at Printing in Qt. There is the QPrinter class that implements some of what you are looking for. It is implmenetent as a QPaintDevice. This means that any widget that can render itself on the screen can be printed. This also mean you don't need to render to a bitmap to print, you can use Qt widgets or drawing functions for printing
On a side note, check the version number of the Qt documentation, the last release of Qt is 4.5, 4.6 is in beta.
You might want to investigate wx python for printing. Learning the framework might be a bit of an overhead for you though! I've had success with that in the past, both on windows and linux.
I've also used reportlab to make PDFs which are pretty easy to print using the minimum of OS interaction.
I would use PIL to create a BMP file, and then just use the standard OS services to print that file. PIL will accept data in either raster or vector form.