AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
April 2005

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date


The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems

Valid HTML 4.01!


2005.04.28 13:40 "Delphi 7, TIFF G3/4, Multipage", by Matthias Lach
2005.04.29 16:09 "Re: Delphi 7, TIFF G3/4, Multipage", by Joris Van Damme

2005.04.29 16:09 "Re: Delphi 7, TIFF G3/4, Multipage", by Joris Van Damme


> I can open and see my file with
> "image1.Picture.Bitmap:= ReadTiffIntoBitmap(filename);"
> and can see the TIFF in my Image-Obj on the Form.

ReadTiffIntoBitmap is not part of LibTiffDelphi. It is thus helpful to mention
where it came from...

ReadTiffIntoBitmap returns a TBitmap. Your calling code now 'owns' the TBitmap.
The statement 'Picture.Bitmap:=x' is the same as 'Picture.Assign(x)'. It does
not transfer ownership of the TBitmap to the TImage, but makes a 'deep copy'
instead (which boils down to incrementation of some usage counters and only a
copy of some small upper-level objects, so is still fast). As a result, your
calling code still owns the original TBitmap... and it fails to Destroy it.
Potentially huge memory leak.

Instead, do something like...
  m: TBitmap;
  {add error handling too!!!!!!}

> - how can i make a the opened file fit into my Image-Obj ?

TImage has properties like Stretched and stuff... see your Delphi docs.

> - show width, hight, resolution, and pages! (multi-/single-page)

Ask the value of individual tags in a TIFF IFD with TIFFGetField.

For instance, to open a TIFF file, retrieve first page image width, and next
close it again, use this:

  OpenTiff: PTIFF;
  FirstPageWidth,FirstPageHeight: Cardinal;
  if OpenTiff=nil then raise Exception.Create(
           'Unable to open file '''+Filename+'''');
  {FirstPageWidth and FirstPageHeigth are now what you are after}

The thing to remember here, is that a TIFF 'image header' is not a fixed set of
fields, like is the case with most image file formats. Instead, it's a set of
tags, and it can contain any tags the writer choose to write. For an overview of
most known tags, see

> - how to cut off lines ?
> - how to raotate?

These are not things that are the responsability of LibTiff. Remember, LibTiff
is a TIFF codec, which means it is able to decode and encode a TIFF file, not
actually do image editing.

The proper way, is to delegate such stuff to things like TBitmap and such. In
Delphi, you would probably do this to open a TIFF, read the first page into a
TBitmap, and next make a second TBitmap that does not include upper two lines
(but this is from the top of my head, and I don't usually use this stuff, so

  m: TBitmap;
  n: TBitmap;
  {n is now your image decoded from filename TIFF file, minus upper two lines}
  {you now own n here, and need to destroy or something in the end}

Same principle goes for rotating and stuff, you don't want to depend on
LibTiffDelphi for that, you'll need to read the Delphi docs and play around with
TBitmap and stuff.

> - what would be the way to handle mulit-part-tiffs?

See, and more specifically and

Joris Van Damme
Download your free TIFF tag viewer for windows here: