c++ - QPrinter resolution is wrong in Linux -
c++ - QPrinter resolution is wrong in Linux -
i trying image printing programme work in qt. trying print custom printer have ppd. there calculations based on device information, create image sent printer.
when looking @ printer properties, see resolution
300 dpi x 300 dpi
.
in windows, works fine - in linux, calculated image info becomes large, making files explode... looking through info found in linux, physicaldpix
, physicaldpiy
(used in code calculation) 1200 instead of 300.
so blame on qprinter::printermode
qprinter::highresolution 2 on windows, sets printer resolution defined printer in use. postscript printing, sets resolution of postscript driver 1200 dpi.
i changed constructor take care of - in case defaults wrong... didn't work:
printer::printer(const qprinterinfo& printerinfo, mainwindow* pwnd) : #if defined(q_os_win32) || defined (q_mac_osx) qprinter(qprinter::highresolution) #else qprinter(qprinter::screenresolution) #endif { qdebug()<<"printer resolution physicaldpix="<< this->physicaldpix()<<", physicaldpiy="<<this->physicaldpiy(); // prints 1200 each in linux, 300 in windows qdebug()<<"printer resolution="<< this->resolution(); // prints 96 in linux, 300 in windows // printer properties (like system-config-printer) show 300 // printerinfo.printername() , printerinfo.defaultprinter().printername() show printer }
the numbers wrong resolution in linux, right in windows
tried
this->setresolution(300);
it made this.resolution() become 300, physicaldpix , y show 1200 still.
qprinter::supportedresolutions () seems case hopeless...
how create printer see resolution shown in printer properties ?
is hope pull methods cups ? tried... don't understand how utilize piece of info found: cups resolution
first, never rely on physical device resolution. user may utilize printers different resolutions, print 1 time 1 resolution (300dpi), next time other resolution (600dpi) or may print pdf file, or open print preview window uses screen resolution. second, utilize screenresolution printing screen, high resolution device much rough. letters , images ugly , positioning on page low precision.
printing independent on physical device resolution , operating scheme also, can achieved qpainter scaling. far know, qpainter base of operations resolution 1200dpi. means finest effective resolution qt can print. next illustration shows how set scaling before drawing contents on page.
qprinter printer(qprinter::highresolution); qreal resolutionfactor = 1200 / printer->resolution(); qpainter painter; painter.begin(&printer); painter.scale(1 / resolutionfactor, 1 / resolutionfactor); printpage(&painter); // method should implement printing painter.end();
then implement contents drawing (set x , y coordinates, width , height images, etc) base of operations qpainter resolution of 1200dpi , rendering process take care sizes automatically scaled resolution of target device.
c++ linux qt printing resolution
Comments
Post a Comment