Page 1 of 1

Image loaded for Annotation is too small

Posted: Thu Jul 12, 2018 7:46 pm
by whoit
Hi -

I'm experiencing a problem where I load any raster image from file and the resulting size is too small.

Specifically, I have a 100x100 pixel sample that is loaded as 72x72 and of course is too small
when placed onto a page.
This happens with every raster image I try - bmp, jpg, png.

I'm using the CoreAPI C# Sample code from Alex (https://github.com/tracker-software/PDF ... oreAPIDemo)
and looking at the values returned in this line:

Code: Select all

//LoadStampFromTheImageFile
si.GetSize(out nWidth, out nHeight);
Can you please address this?

Thanks,
Wayne

Re: Image loaded for Annotation is too small

Posted: Fri Jul 13, 2018 6:34 am
by Sasha - Tracker Dev Team
Hello Wayne,

Are you able to reproduce in the "6.4. Load stamp from image file" sample itself (24*24 image is being loaded there)?

Cheers,
Alex

Re: Image loaded for Annotation is too small

Posted: Fri Jul 13, 2018 1:50 pm
by whoit
Hi Alex -

OK, I did some more testing and this is what I found:

1) I have two sample images - A.png and B.png
A.png is 72x72 @ 72dpi
B.png is 80x31 @ 150dpi

2) When I use A.png as an IPXC_Image (for general placement on a page)

Code: Select all

IPXC_Image AImage = pDoc.AddImageFromFile("A.png");
it is returned as 72x72 pixels

When I use A.png as an Annotation Image loaded into a Collection, etc.:

Code: Select all

IAFS_File tmpFile = fsInst.DefaultFileSys.OpenFile(tmpName, openFileFlags);
it is also returned as 72x72 pixels.

3) However, if I use B.png in both scenarios,
when loaded as an IPXC_Image it is returned as 80x31 (the dpi is ignored)
but when loaded for an Annotation it is returned as 38x15 (the dpi is implemented)

So, my questions are:

A) Why does one method return the size without regard to dpi (IPXC_Image)
but the other method (Annotation) returns the size based on 72 dpi ?

B) How can I ensure that regardless of the "image loading method" that I use, I can get
consistent results without first knowing the image dpi?
For example, how can I ensure that both of the above sample images either adhere to
72dpi, or ignore the dpi ?

Thanks....

Re: Image loaded for Annotation is too small

Posted: Tue Jul 17, 2018 6:20 am
by Sasha - Tracker Dev Team
Hello Wayne,

This behavior occurs, because you have different measurement unit types - the IIXC_Page (like every raster) has pixel unit type. The DPI is used to convert pixels into the metrical units.
When you convert PNG into PDF, our converter takes the image DPI into an account and creates a content with corresponding size (and the size of the content is measured in points).
Thus 72 pixels with 72 DPI equal 1 inch (72/72) that equals 72 points for the first image.
As for the second image, 80 pixels with 150 DPI will equal 72*80/150 = 38.4 points.

Cheers,
Alex

Re: Image loaded for Annotation is too small

Posted: Tue Jul 17, 2018 12:22 pm
by whoit
Hi Alex -

So the basic answer is that a raster file when used for Annotation is actually converted to a PDF format,
which then implements the original image DPI - Correct?

Re: Image loaded for Annotation is too small

Posted: Tue Jul 17, 2018 12:38 pm
by Sasha - Tracker Dev Team
Hello Wayne,

Basically this is a short answer:
When you convert PNG into PDF, our converter takes the image DPI into an account and creates a content with corresponding size (and the size of the content is measured in points).
Cheers,
Alex