Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
Imported Image Resolution |
Post Reply |
Author | |
MarcoAbbate
Beginner Joined: 23 Mar 15 Location: Rome - Italy Status: Offline Points: 6 |
Post Options
Thanks(0)
Posted: 24 Mar 15 at 9:15AM |
Hi everybody!
I'm facing a strange behaviour importing images using the function "DrawImage". I have a JPEG image with a resolution on 150DPI. Its dimensions are 404x275 mm. When I import the image, the PDF page has the dimensions of 841.7x573.3 mm. After some tests I found the dimensions of the PDF page are equal to the image dimesions IF THE IMAGE WAS AT 72DPI... I tried to set the correct dimensions as follows, even if some functions are redundant: int pW=QP.ImageWidth(); int pH= QP.ImageHeight(); QP.SetPageDimensions(pW ,pH); QP.SetImageResolution(150, 150, 2); QP.FitImage(0, 0, pW, pH, 0, 0, 0); QP.SetOrigin(1); i = QP.DrawImage(0, 0, pW, pH); i = QP.SaveToFile(filePDF); But I always get the same wrong dimensions (841.7x573.3 mm) in the output. I tried to import JPEG, TIFF and BMP image, always with the same wrong result. Note the images by themselves are correct, with the right ( 404x275 mm). Do you have any hint or solution about this issue? Thank you very much in advance! Marco. |
|
MarcoAbbate
Beginner Joined: 23 Mar 15 Location: Rome - Italy Status: Offline Points: 6 |
Post Options
Thanks(0)
|
SOLUTION FOUND !!!
The problem is due to the fact that in any case the imported image is managed as it would have a resolution of 72 DPI. In this case the PDF page takes its dimensions according to this wrong assumption. To solve the problem it is mecessary to apply a scale factor from the default wrong 72 DPI resolution to the right one: Note DPIres is the real image resolution... double ImageWidthInPoints = (double)QP.ImageWidth() / dpix * DPIres; double ImageHeightInPoints = (double)QP.ImageHeight() / dpiy * DPIres; int pW=QP.ImageWidth(); int pH= QP.ImageHeight(); QP.SetOrigin(1); i = QP.DrawImage(0, 0, pW, pH); float stdRes = 72; float PageScale = stdRes / DPIres; QP.SetPageDimensions((pW * PageScale), (pH * PageScale)); QP.FitImage(0, 0, (pW * PageScale), (pH * PageScale), 0, 0, 0); i = QP.SaveToFile(filePDF); |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store