2005.01.23 16:43 "[Tiff] LibTiffDelphi", by Michel Salvagniac

2005.02.08 16:43 "Re: [Tiff] LibTiffDelphi", by Joris Van Damme

Miko,

> I test LibTiffDelphi with a program i've found here:

Thank you for using LibTiffDelphi! Please accept my appologies for this very late reply.

Your code is mostly fine.

> TIFFSetField(imgtif, TIFFTAG_XRESOLUTION, 150.0);
> TIFFSetField(imgtif, TIFFTAG_YRESOLUTION, 150.0);
>...
> Last problem, the resolution is not what it could be, tiffinfo says:

For some strange reason, the only alternative that works seems to be if you pass the resolution value as a variable of type Double, instead of a direct value. This probably has something to do with an interpretation of the 'varargs' scheme and/or constants in Delphi, that is slightly off, compared to C++ Builder, but I don't know for sure...

So change that part of your code to:

var
  m: Double;
begin
  m:=150.0;
  TIFFSetField(imgtif, TIFFTAG_XRESOLUTION, m);
  TIFFSetField(imgtif, TIFFTAG_YRESOLUTION, m);

If anyone here is more familiar with the deep intricacies of Borland C++ Builder and Delphi calling conventions, in particular in relation to this cdecl varargs issue, and might be able to explain this odd need for a variable, I'd very much like to hear about it.

> the images produced are inverted (...top=bottom).... for the top/bottom i
> don't know how to play with TIFFTAG_ORIENTATION.

If that is allright for your purpose, it is best not to use the TIFFTAG_ORIENTATION tag, since most mainstream readers ignore it anyway. It's far better to change the order in which you provide the scanlines in the scanline writing part of your code, which is currently 'upside down'. Try something like this:

  for y := 0 to Height - 1 do
  begin
    if TIFFWriteScanLine(imgtif, Scanline[y], y, 0)<>1 then ...
  end;

> the images produced are inverted (black = white...). The
> black/white problem seem to be a Microsoft issue

Yes, there are some issues, some readers get it wrong in some situations... All us writers can do, is try and get it right, of course. We can't fix Microsoft's bugs, but we can't yield to them either, since that will produce faulty TIFFs that display incorrectly even in Microsoft's software if they should one day correct that bug....

Currently, you are using PHOTOMETRIC_MINISWHITE. It may be good to doublecheck if that matches your source image... For instance, a TBitmap that is set to contain PixelFormat pf1bit, should be written using photometric PHOTOMETRIC_MINISBLACK, instead.

> TIFFSetField(imgtif,TIFFTAG_SOFTWARE, 'LibTiffDelphi');

Thanks, that's very kind!

Best regards,

Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html