Problem loading images

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Problem loading images

Post by DolphinMann »

I am having issues when attempting to load images.

The following code fails:

this.result = PDFXC_Funcs.PXC_AddImageW(this.pdfObject, newImage, out imageOut);

In the above case I can confirm that I have a valid pdfObject and the newImage(string path to JPG or TIFF file) is valid and the file is not locked. This continuously fails with invalid file format no matter what the path or the image I attempt to load is.

However if I change that above line to:
Bitmap b = new Bitmap(newImage);
IntPtr bitmapPointer = b.GetHbitmap();
GCHandle handle1 = GCHandle.Alloc(b.Palette);
IntPtr palettePointer = (IntPtr)handle1;
this.result = PDFXC_Funcs.PXC_AddImageFromHBITMAP(newPDFObject, bitmapPointer, palettePointer, out imageOut);

It all of a sudden works. The path is the exact same, nothing at all has changed other than I am adding the image from HBITMAP instead of a filepath. Clearly I am doing something wrong as I've seen other posts from people claiming this works.

I understand the solution/issue may not be evident from the above alone, but what other information can I provide? I am confused as to why all other surrounding code is the exact same but changing it to load from a windows bitmap instead of a file path works.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17889
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Problem loading images

Post by Tracker Supp-Stefan »

Hello DolphinMann,

Do you have the fm40*.dll dlls included in your project?
Those are the ones responsible for the image formats in question:
Redistribution of PDF-XChange Libraries

Regards,
Stefan
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: Problem loading images

Post by DolphinMann »

I almost certainly do not and I think I missed that entire section of documentation you linked.

Thank you for the response. Let me take a look at that and post my results.

-Mark
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Problem loading images

Post by Will - Tracker Supp »

Let us know how it goes :)
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: Problem loading images

Post by DolphinMann »

That fixed everything for me. Thank you.
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Problem loading images

Post by Will - Tracker Supp »

:)
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
Post Reply