#include <QApplication>
#include <QString>
#include <QTextStream>
#include <QRgb>
#include <QImage>
#include <QPainter>
int main(int argc, char *argv[])
{
if(argc == 2)
{
// just add any parameter for gui mode
printf("Running in GUI mode\n");
}
else
{
printf("Running in CONSOLE mode\n");
}
out << "physicalDpi: x=" <<
device->physicalDpiX()
<<" y="<< device->physicalDpiY() << endl;
out << "logicalDpi: x=" <<
device->logicalDpiX()
<<" y="<< device->logicalDpiY() << endl;
return 0;
}
#include <QApplication>
#include <QString>
#include <QTextStream>
#include <QRgb>
#include <QImage>
#include <QPainter>
int main(int argc, char *argv[])
{
QCoreApplication *app = 0;
if(argc == 2)
{
// just add any parameter for gui mode
printf("Running in GUI mode\n");
app = new QApplication(argc, argv);
}
else
{
printf("Running in CONSOLE mode\n");
app = new QCoreApplication(argc, argv);
}
QTextStream out(stdout);
QImage image(128, 128, QImage::Format_ARGB32);
QPainter painter(&image);
QPaintDevice *device = painter.device();
out << "physicalDpi: x=" <<
device->physicalDpiX()
<<" y="<< device->physicalDpiY() << endl;
out << "logicalDpi: x=" <<
device->logicalDpiX()
<<" y="<< device->logicalDpiY() << endl;
return 0;
}
To copy to clipboard, switch view to plain text mode
Here's the result on my Mac:
$ BugTest
Running in CONSOLE mode
physicalDpi: x=75 y=75
logicalDpi: x=75 y=75
$ BugTest gui
Running in GUI mode
physicalDpi: x=72 y=72
logicalDpi: x=72 y=72
I would accept this change if I paint on the screen - but its painted in a background buffer.....
I am currently a bit unsure on how to proceed now...
Create a new QPaintDevice and override
virtual int metric ( PaintDeviceMetric metric ) const ?
Or use QImage setDotsPerMeterX/Y ?
Bookmarks