2009.09.21 14:41 "[Tiff] How to read extended tags with LibTiffDelphi in Delphi 7", by Ivan Micetic

Dear all,

I am trying to read extended tags from a tiff file in Delphi 7 and I tried to implement it from a C code snippet found in the mailing list but with no luck. I have tried something like the following but it has errors:

...
const
  TIFFTAG_ASCIITAG=34682;
...
procedure TForm1.Button1Click(Sender: TObject);
var
  TestStr:string;
  xtiffFieldInfo:PTIFFFieldInfo;
  OpenTiff: PTIFF;

procedure TagExtender(Handle: PTIFF);
begin
  New(xtiffFieldInfo);
  xtiffFieldInfo^.FieldTag:=TIFFTAG_ASCIITAG;
  xtiffFieldInfo^.FieldReadCount:=-1;
  xtiffFieldInfo^.FieldWriteCount:=-1;
  xtiffFieldInfo^.FieldType:=TIFF_ASCII;
  xtiffFieldInfo^.FieldBit:=FIELD_CUSTOM;
  xtiffFieldInfo^.FieldOkToChange:=1;
  xtiffFieldInfo^.FieldPassCount:=0;
  xtiffFieldInfo^.FieldName:='MyTag';
  TIFFMergeFieldInfo(Handle,xtiffFieldInfo,1);
end;

begin
  TIFFSetTagExtender(@TagExtender);
  OpenTiff:=TIFFOpen('file.tif','r');
  TIFFGetField(OpenTiff,TIFFTAG_ASCIITAG,@TestStr);
  Label1.Caption:='>>>'+TestStr+'<<<';
end;

Could somebody let me know how to read/write an extended ascii and other type of tags in Delphi?

Thank you in advance,

Ivan Micetic