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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Imported Image Resolution
  FAQ FAQ  Forum Search   Register Register  Login Login

Imported Image Resolution

 Post Reply Post Reply
Author
Message
MarcoAbbate View Drop Down
Beginner
Beginner
Avatar

Joined: 23 Mar 15
Location: Rome - Italy
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote MarcoAbbate Quote  Post ReplyReply Direct Link To This Post Topic: Imported Image Resolution
    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.

Back to Top
MarcoAbbate View Drop Down
Beginner
Beginner
Avatar

Joined: 23 Mar 15
Location: Rome - Italy
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote MarcoAbbate Quote  Post ReplyReply Direct Link To This Post Posted: 25 Mar 15 at 11:41AM
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);
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store