qt


Qt 4.8, Screenshot of large QGraphicsScene


I have QGraphicsScene, which size is 62450x4750. Somethimes I need to make screenshot of whole scene and save it to file. I tried like this:
QPixmap wholeScene(scene.sceneRect().size().toSize());
{
QPainter wholeScenePainter(&wholeScene);
scene.render(&wholeScenePainter);
}
// saving pixmap
or
QPixmap wholeScene(scene.sceneRect().size().toSize());
{
QPainter wholeScenePainter(&wholeScene);
int x = 0;
int portion = 32768; //
while( x < scene.sceneRect().width()) {
int width = scene.sceneRect().width() - x > portion ? portion : scene.sceneRect().width() - x;
QRect rect(x, 0, width, scene.sceneRect().height());
scene.render(&wholeScenePainter, rect, rect);
x += width;
}
}
// saving pixmap
or
QPixmap wholeScene(scene.sceneRect().size().toSize());
{
QPainter wholeScenePainter(&wholeScene);
int x = 0;
int portion = 4096;
while( x < scene.sceneRect().width()) {
int width = scene.sceneRect().width() - x > portion ? portion : scene.sceneRect().width() - x;
QRect rect(x, 0, width, scene.sceneRect().height());
QPixmap temp(rect.size());
QPainter p(&temp);
scene.render(&p, QRect(0, 0, rect.width(), rect.height()), rect);
wholeScenePainter.drawPixmap(x,0, temp);
//temp.save(QString("print%1.png").arg(QString::number(x)), "PNG");
x += width;
}
}
// saving pixmap
But every time I get the Image(Pixmap) cuted by width on 32768 px.
According to the documentation, QPainter does not support coordinates larger than +/- 32768. This does not appear to be fixed in Qt 5 either.
Maybe you can solve this by rendering the scene in multiple passes, e.g. through translation and clipping. You can render the scene in multiple blocks of max 32768x32768 pixels and put them in the proper position in the final image.

Related Links

QSignalMapper with signal argument and extra argument
Error while set up absolute image path in QML/QT (under Windows)
QProcess not work with start but work with startDetached
QSocketNotifier: socket notifiers cannot be disabled from another thread
qmake eval function “always true” for string literals
Implementing a GUI Shell in qt
Get rid of Qt's dotted outline on QListView items
How to stop the transition animation in QML?
How does Qt on Windows draw exactly? Does it call GDI internal to draw?
QML: aliases to children properties
QTreeView remove decoration/expand button for all items
Share window created in Qt C++ with PyQt
Qt: QLineEdit cursor moves to end after textChanged() or commitData()
How can I extract plain text (no markup) from QWebElement?
How can I paint on a specific pixel in BlackBerry 10, Qt QML Cpp
Size of Qt containers: is QMap much larger than Qlist?

Categories

HOME
qt
jboss
apache-nifi
windows-8.1
stacktrace.js
plaid
odata
consul
yql
amp
turbojpeg
fedora
jpa-criteria
mailing-list
wine
multi-step
jqxgrid
hidden
angular2-highcharts
error-logging
web-analytics
quantitative-finance
router
plyr
unrar
list-comprehension
onchange
iwebbrowser2
amazon-cloudtrail
locks
source-insight
cucumber-junit
overwrite
kendo-listview
express-session
rails-postgresql
buildforge
orchardcms-1.8
nppexec
cups
pdfnet
jade4j
xll
assert
python-sounddevice
netapp
vb.net-to-c#
flipkart
1wire
doctrine-extensions
music21
photoswipe
nonlinear-functions
entropy
maven-jaxb2-plugin
dtd
oid
java-2d
tablespace
jpda
coovachilli
cdo.message
powerpoint-2013
adjacency-list
android-async-http
jsr363
certificate-authority
webgrind
cryptojs
godeps
google-maps-api-2
wlanapi
darwin
kotlin-android-extensions
findersync
inputbox
lmax
ecos
coding-efficiency
distributed-r
nachos
csslint
assetic
progress-db
colon
iirf
node.js-stream
xs
oscilloscope
office-app
linkbutton
android-dialog
struts2-s2hibernate
yuidoc
dynamic-c
glassfish-esb
fragment-identifier
cassini
android-input-method
resharper-5.0
twitter-feed
prism-2

Resources

Encrypt Message