AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

2014.11.29 22:27 "[Tiff] Delphi TIFFGetField with Count > 1 fails", by Rick Widmer

I am having a problem with LibTiffDelphi version 3.7.0.00.

The first question, is there anything newer, especially a version that supports bigtiff files?

If not, is there a more recent Windows DLL for libtiff available somewhere? I'm willing to try updating LibTiffDelphi, but I can't compile C/C++== on Windows.

My problem:

I am using TIFFGetFIeld() to retrieve various tags that have more than one entry. (Count > 1)

Single entry values, and the first value when there are more, are retrieved correctly. If there is more than one entry only the first is returned. For example, tag 258 (BitsPerSample) returns 8 where I expected 8, 8, 8. I have also looked at tag 324 (TileOffsets) and 325 (TypeByteCounts), again only the first value of many is returned.

Does anyone have a suggestion, or example Delphi code that properly returns all the values contained in tags like these?

My Code:

==============================================================================

GetField is a method in the TBigTiffCache. All it does is move the TIFF Handle into the TTiffFile object so I don't have to pass it with every call. I can't imagine the problem is here, but just in case...

function TTiffFile.GetField( Tag: Cardinal; p: pointer ): Cardinal;
begin
result := LibTiffDelphi.TIFFGetField( fTiff, tag, p );
end;

==============================================================================

showShort is part of a collection of methods that return a string containing the value of a tag. ShowShort is used for tags of type 3. I get similar results from showLong which uses a longword for the buffer and handles type 4 tags.

function tShowIFD.showShort( tiff: TtiffFile; tag: cardinal; count:

cardinal ): string;
var
    b: array of word;
    i: word;

begin
// added for debugging only. look past expected data
if count < 10 then count := count + 10;

setlength( b, count );

// added for debugging only. tried values 0, 1, 255 to make sure // I know what was actually written to the buffer by GetField. fillchar( b[0], count * 2, 1 );

tiff.GetField( tag, @b[0] );

// always return the first value
result := inttostr( b[0] );

// If more than one, return them, with ', ' between each
if count > 1 then for i := 1 to count - 1 do
     begin
         result := result + ', ' + inttostr( b[i] );
     end;
end;

==============================================================================