| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 2 | |
Hi all, I would like to generate a PDF doc with one image per page: the images are fitting completely the page) and they have a big resolution (about 3000x2000 pixels). Now, I use the QPrinter class painting the images on it using QPainter. The problem is that, even knowing that QPrinter compresses the images, the resulting PDF doc is much larger that the group of images. I'm nearly sure that QPrinter or QPainter fixes somewhere internally the compression level of the images wirtten on a PDF doc, so I would like to know where to change it (if it's possible). Another question is why QPrinter simply doesn't include the original image (like an attachment)? I think that it would be easier... Thanks. Automóviles, telefonía, imagen y sonido, belleza ¡Encuentra todo lo que necesitas! http://clasificados.orange.es
On Saturday 09 December 2006 21:43, skript1@xxxxxxxxxx wrote: > Hi all, I would like to generate a PDF doc with one image per page: the > images are fitting completely the page) and they have a big resolution > (about 3000x2000 pixels). Now, I use the QPrinter class painting the images > on it using QPainter. The problem is that, even knowing that QPrinter > compresses the images, the resulting PDF doc is much larger that the group > of images. I'm nearly sure that QPrinter or QPainter fixes somewhere > internally the compression level of the images wirtten on a PDF doc, so I > would like to know where to change it (if it's possible). Another question > is why QPrinter simply doesn't include the original image (like an > attachment)? I think that it would be easier... Thanks. You might need to explain what you are trying to do, perhaps with a small code example, however I think that if you read a large jpeg image into a QImage, and then paint that, then print it, expecting it to turn back into a jpeg image in a PDF is optimistic. Brad
Attachment:
Attachment:
pgpLErNbM3SyH.pgp
Description: PGP signature
Message 3 in thread
Brad, all I want is to know if the images written on a PDF doc are compressed (as I think) and, in that case, if it's possible to change the compression level somewhere in the QPrinter or QPainter class. The other solution, as I've mentioned before, would be not painting the image but attach it as it is (as other software does). Thanks. <br /><i><b> </b></i><br />
<a href="http://desktop.orange.es" target="_blank">Disponible con un clic. ¡Descarga Gratis Orange Desktop Search y encuentra todo tipo de archivos en tu PC!</a>
Message 4 in thread
skript1@xxxxxxxxxx wrote:
> Brad, all I want is to know if the images written on a PDF doc are
> compressed (as I think) and, in that case, if it's possible to change
> the compression level somewhere in the QPrinter or QPainter class. The
> other solution, as I've mentioned before, would be not painting the
> image but attach it as it is (as other software does). Thanks.
> /* */
You change it in qprintengine_pdf.cpp:517, at least in Qt Windows 4.2.2 ;-)
Seriously, you should reconsider your approach. I don't know if you
uncompress the images, however, just circumventing QPainter completely
and creating simple PDF files where one image always matches a page
isn't that hard. Check out www.pdflib.com for a dual-licensed library
that might help you out.
/eno
--
[ signature omitted ]
Message 5 in thread
Thanks /eno for your suggestion. But I would like that, before searching for other libraries, be sure if it's possible to change the compression level of the images written on a PDF doc unsing Qt. I've searched in the file qprintengine_pdf.cpp and there are various methods that seems to manage the images wirtten on a PDF doc:<br />- "QPdfEnginePrivate::addImage": in some place calls to QImageWritter::setQuality with value 94 and format "jpeg". So, seems that my first supposition was true and it fixes a compression level. Then, it calls to QPdfEnginePrivate::writeImage.<br />- "QPdfEnginePrivate::wirteImage" calls to QPdfEnginePrivate::writeCompressed<br />- "QPdfEnginePrivate::writeCompressed" calls to "compress" if QT_NO_COMPRESS is not defined.<br /><br />So, my questions are:<br />- Is QT_NO_COMPRESS defined or not by default on Qt 4.2.1?<br />- When I call to QPainter::begin with a QPrinter instance (configured with PDFormat as output) and then I draw an image with QPainter::drawPixmap, would it write the image on the PDF calling to QPdfEnginePrivate::addImage?<br /><br />Thanks again<br /><br /><br /><br /><br /><br /><br />
<a href="http://clasificados.orange.es" target="_blank">Automóviles, telefonía, imagen y sonido, belleza? ¡Encuentra todo lo que necesitas!</a>
Message 6 in thread
Hi,
> - Is QT_NO_COMPRESS defined or not by default on Qt 4.2.1?
No, it's not. QT_NO_COMPRESS may be used within Qtopia Core when trying
to reduce the size of the libraries for embedded environments. It's not
defined in Qt.
--
[ signature omitted ]