diff options
Diffstat (limited to 'tests/manual/lance/main.cpp')
-rw-r--r-- | tests/manual/lance/main.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/manual/lance/main.cpp b/tests/manual/lance/main.cpp index 97197f0509..c9458f5657 100644 --- a/tests/manual/lance/main.cpp +++ b/tests/manual/lance/main.cpp @@ -121,6 +121,7 @@ static void printHelp() " -commands Displays all available commands\n" " -w Width of the paintdevice\n" " -h Height of the paintdevice\n" + " -scalefactor Scale factor (device pixel ratio) of the paintdevice\n" " -cmp Show the reference picture\n" " -bg-white No checkers background\n"); } @@ -238,6 +239,8 @@ int main(int argc, char **argv) bool highres = false; bool show_cmp = false; int width = 800, height = 800; + int scaledWidth = width, scaledHeight = height; + qreal scalefactor = 1.0; bool verboseMode = false; #ifndef QT_NO_OPENGL @@ -328,6 +331,9 @@ int main(int argc, char **argv) } else if (option == "h") { Q_ASSERT_X(i + 1 < argc, "main", "-h must be followed by a value"); height = atoi(argv[++i]); + } else if (option == "scalefactor") { + Q_ASSERT_X(i + 1 < argc, "main", "-scalefactor must be followed by a value"); + scalefactor = atof(argv[++i]); } else if (option == "cmp") { show_cmp = true; } else if (option == "bg-white") { @@ -350,6 +356,8 @@ int main(int argc, char **argv) #endif } } + scaledWidth = width * scalefactor; + scaledHeight = height * scalefactor; PaintCommands pcmd(QStringList(), 800, 800); pcmd.setVerboseMode(verboseMode); @@ -514,7 +522,8 @@ int main(int argc, char **argv) #endif case PixmapType: { - QPixmap pixmap(width, height); + QPixmap pixmap(scaledWidth, scaledHeight); + pixmap.setDevicePixelRatio(scalefactor); pixmap.fill(Qt::white); QPainter pt(&pixmap); pcmd.setPainter(&pt); @@ -527,7 +536,8 @@ int main(int argc, char **argv) case BitmapType: { - QBitmap bitmap(width, height); + QBitmap bitmap(scaledWidth, scaledHeight); + bitmap.setDevicePixelRatio(scalefactor); QPainter pt(&bitmap); pcmd.setPainter(&pt); pcmd.setFilePath(fileinfo.absolutePath()); @@ -547,9 +557,10 @@ int main(int argc, char **argv) case ImageType: { qDebug() << "Creating image"; - QImage image(width, height, type == ImageMonoType + QImage image(scaledWidth, scaledHeight, type == ImageMonoType ? QImage::Format_MonoLSB : imageFormat); + image.setDevicePixelRatio(scalefactor); image.fill(0); QPainter pt(&image); pcmd.setPainter(&pt); @@ -557,6 +568,7 @@ int main(int argc, char **argv) pcmd.runCommands(); pt.end(); image.convertToFormat(QImage::Format_ARGB32).save("output_image.png", "PNG"); + image.setDevicePixelRatio(1.0); // reset scale factor: display "large" image. #ifndef CONSOLE_APPLICATION QLabel *label = createLabel(); label->setPixmap(QPixmap::fromImage(image)); |