QML Quick Scene in to PDF via ScreenShot - Poor Resolution
-
Hi,
as faar as i know, i cant draw anything from QML to a file or PDF.
So the only way is to make a screen shot from the window: https://forum.qt.io/topic/28262/solved-how-to-take-screenshot-qt-qml/2Now that i have my QImage and i made my PDF with 300DPI the ScreenShot image doesnt look so nice. My display has a resolution of 1280x800 so the screen shot QImage will have that.
How can i boost up my QImage so it looks good at 300DPI? -
Hi,
as faar as i know, i cant draw anything from QML to a file or PDF.
So the only way is to make a screen shot from the window: https://forum.qt.io/topic/28262/solved-how-to-take-screenshot-qt-qml/2Now that i have my QImage and i made my PDF with 300DPI the ScreenShot image doesnt look so nice. My display has a resolution of 1280x800 so the screen shot QImage will have that.
How can i boost up my QImage so it looks good at 300DPI?@michaelL
what about grabToImage() with a high target size? -
@raven-worx said in QML Quick Scene in to PDF via ScreenShot - Poor Resolution:
high target size
You mean that i could make my target very big and use the grabToImage() function to make it into a picture?
-
@raven-worx said in QML Quick Scene in to PDF via ScreenShot - Poor Resolution:
high target size
You mean that i could make my target very big and use the grabToImage() function to make it into a picture?
@michaelL
i don't know for sure, but simply give it a try:item.grabToImage(function(result) { // do something with "result.url" result.saveToFile("something.png"); }, Qt.size(1280*3, 800*3)); // just some dummy values here
-
QML-to-PDF capture actually used to be easier in the SW-rendered (QPainter-based) original QtQuick1/QtDeclarative. Some related comments on this, and attempts to work round it, at:
- https://stackoverflow.com/questions/20825233/how-to-print-a-qquickviews-contents-to-pdf
- http://blog.qt.io/blog/2016/08/15/the-qt-quick-graphics-stack-in-qt-5-8/ (see the comments on that and https://bugreports.qt.io/browse/QTBUG-55321 )
- https://www.kdab.com/creating-pdf-qtquick-2-scene-slideviewer/
Quite interested to hear what that size argument to grabToImage does. My guess would have been that providing a larger size than the Item it just gets you a fuzzy image of it... but I'd be pleasantly surprised and impressed if it actually re-renders the item and all it's child items at higher resolution.
-
@raven-worx It works!
So i grab my rectangle into an Image and did Qt.size(10003, 6203).
My rectangle has 1000x620 pixel size.
I open the image and it has 3000x1860 pixels. Awesome!