Page 1 of 1

TIFF File Formats

Posted: Sat Feb 27, 2010 8:52 pm
by jeffp
Does the Image XChange Library give me the ability to change file formats. For example, I need to save out an image to file as BW TIFF with CCIT compression regardless of the original format.

Also, can I convert a .bmp or a .jpet to .tiff, and vice versa.

Re: TIFF File Formats

Posted: Mon Mar 01, 2010 7:30 am
by Lzcat - Tracker Supp
Answer is "Yes, it does" for all questions. You can find working sample with installation (including sources). Also please see IMG_PageSetFormatLongParameter and similar functions. And if you will have more questions - you are wellcome.

Re: TIFF File Formats

Posted: Tue Mar 02, 2010 12:01 am
by jeffp
I've looked at the help topic for IMG_PageSetFormatLongParameter and figured it had to do with the id and value properties, but the help doesn't give any more info on id and value and their possible values.

I looked around for some Delphi examples but can't find then in the SDK. Can you direct me to the right Delphi examples for this. I'm sure I'm just missing it somewhere.


Re: TIFF File Formats

Posted: Tue Mar 02, 2010 5:11 am
by John - Tracker Supp
There is only the one Delphi example Jeff and not being a Delphi DEV I cannot advise specifically - but here is the example in case you missed it ..

Re: TIFF File Formats

Posted: Tue Mar 02, 2010 2:57 pm
by jeffp
Yes. I did see this example, but I didn't find anyting in it that will help me with the conversion of file formats and the use of the IMG_PageSetFormatLongParameter call. Am I missing something?

Is that more explanation of the id and value properties in IMG_PageSetFormatLongParameter somewhere?

Re: TIFF File Formats

Posted: Tue Mar 02, 2010 5:17 pm
by Lzcat - Tracker Supp
I'm afraid not, at least at the moment. And I'm afraid that the Delphi sample is not good enough to illustrate fully all the Image-XChange possibilities.

Better to look I would suggest at the C++ sample named ImagesTest, especially the file encoders_dlg.cpp - there is code there which interprets format-specific parameters (see the following explanation).

Image-XChange was designed to support different formats, so it does not contain any format-specific functions like SaveTiffFile etc. Instead we decided that each page (yes, page, not image) contains a list of properties, identified by an ID. Each property has a fixed type (int, double, string), and a page can have any set/combination of them.

When format-specific code (located in the format dll, outside of the Image-XChange core) reads a page from a file it fills all possible properties for each page. And when such code tries to save a file it examines all pages and checks for the specified properties - some of properties will be ignored (if format does not support them), some of them will be corrected (if invalid values are set), and then saves the file.

Since the Image-XChange core and likely the user know almost nothing about format-specific properties - each format library provides a structure which describes all supported properties and their types. In addition for the save structure it is a bit more complex - to contain format-specific dependencies between properties.

There is a good example of how to deal with such structures - decoders_dlg.cpp (for a description of the full properties, see IMG_GetFormatOpenParams function) and encoders_dlg.cpp mentioned above (description for the properties supported when save is set, see the IMG_GetFormatSaveParams function).

In truth - the properties set is almost the same, except some of them cannot be acquired during reading (e.g. compression level). Properties are set as un-unified (and cannot be unified), however we try to keep a minimal set of them.

Also, there are two properties that are present in all formats:

FP_ID_FORMAT - contains the file format identifier; present when read, required for save
FP_ID_ITYPE - contains the image type (unified list of image types, not all formats support all possible values); required for a 'save'

To see all supported properties for a specific format you may run the ImagesTest app and select the Decoders list and Encoders list from the View submenu.

For example if you want to save a multi-page image to a tiff file, black and white and with CCITT compression you should set as below : (for ALL pages):

FP_ID_ITYPE to ImageFormat_BlackAndWhite_1

Possibly looks a little complex, but we haven't found a simpler and more flexible way.

Re: TIFF File Formats

Posted: Tue Mar 02, 2010 5:45 pm
by jeffp
Thanks Victor. I like your approach. And I'll install the C++ exmaples and take a look for more deatails.

But I assume the call would be something like this for all pages:

IMG_PageSetFormatLongParameter(page, FP_ID_FORMAT, FMT_TIFF_ID);
IMG_PageSetFormatLongParameter(page, FP_ID_ITYPE, ImageFormat_BlackAndWhite_1);
IMG_PageSetFormatLongParameter(page, FP_ID_COMP_TYPE, IComp_CCITTFax4);

Then I would just call IMG_ImageSaveToFile to save the file out to disk.

This begs the question then, where are all the ID and Values defined. Shouldn't they be in some .pas unit?

Re: TIFF File Formats

Posted: Tue Mar 02, 2010 6:46 pm
by Lzcat - Tracker Supp
Yes, your are correct with function calls :)
ID's and values are defined in C++ headers (.h files), supplied with the examples, and I'm afraid that not all of them are translated to Delphi. Please see the file ixcfmtdefs.h (hope you can read C++ notation).

Thanks !

Re: TIFF File Formats

Posted: Tue Mar 02, 2010 7:43 pm
by jeffp
Perfect. Thanks much. I know how to take it from here.

Re: TIFF File Formats

Posted: Tue Mar 02, 2010 9:11 pm
by John - Tracker Supp
Hi Jeff,

as you can see from the above Victor (Lazycat) knows his stuff - even if the message needs a little understanding sometimes, hence the reason I have corrected the syntax and formatting a little - but the info is all there ! (Thanks Victor:) )

Re: TIFF File Formats

Posted: Tue Mar 02, 2010 9:19 pm
by jeffp
No worries. The quality of your product is proof enough you know your stuff. I understand the posts just fine. I've worked with enough overseas developers to know not to read anything into broken English. I'm sure my Russian, French, or Canadian <g> would be much worse.

Re: TIFF File Formats

Posted: Tue Mar 02, 2010 10:57 pm
by John - Tracker Supp
Appreciate your understanding Jeff and whilst I have an excellent understanding of profanity in many languages - my useful, general and technical vocabulary is almost non-existent ;)