AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2004.12.21 13:01 "[Tiff] Read X and Y Resolution", by Manuel_Galán
2004.12.21 13:07 "Re: [Tiff] Read X and Y Resolution", by Chris Losinger
2004.12.21 15:25 "Re: [Tiff] Read X and Y Resolution", by Joris

2004.12.21 13:01 "[Tiff] Read X and Y Resolution", by Manuel_Galán

Hi list, this is my first message to the list. I'm begginer with the libtiffDelphi and i'm in trouble with the tiff resolution tags.

I'm using this code, in Delphi7:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  han: PTIFF;
  m, u, resunit: Cardinal;
  xres, yres: integer;
begin
  if OpenDialog1.Execute then
  begin
    han:=TIFFOpen(OpenDialog1.Filename,'ru');
    if TIFFGetField(han, TIFFTAG_IMAGEWIDTH,@m)>0 then label1.caption:= inttostr(m);
    if TIFFGetField(han, TIFFTAG_IMAGELENGTH,@u)>0 then label2.caption:= inttostr(u);
    TIFFGetField(han, TIFFTAG_RESOLUTIONUNIT,@resunit);
    case resunit of
     1: label5.caption:= '?';
     2: label5.caption:= 'inch';
     3: label5.caption:= 'cm';
    end;
    xres:= 0;
    yres:= 0;
    TIFFGetField(han, TIFFTAG_XRESOLUTION,@xres);
    TIFFGetField(han, TIFFTAG_yRESOLUTION,@yres);
    label3.caption:= inttostr(xres);
    label4.caption:= inttostr(yres);
  end;
end;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

when i define xres and yres as double i obtain 5.56078e-315
and when defined as integer i obtain 1125515264

but if i open the file with astifftagviewer i can see the correct resolution (150 pixels per inch)

What is wrong in my code? There is an example in delphi for that?

Thanks in advance

Manuel, from Spain