2011.05.05 16:44 "[Tiff] Is LibTiff 3.9.5 Thread Safe ?", by Katerina Sedivy

2011.05.05 15:03 "[Tiff] Access Violation on TiffClose()", by Katerina Sedivy

Hi,

I have recently downloaded LibTiff 3.9.5 and built it using nmake. I
modified the makefile a little to embed the manifest as a resource into the
DLL since LoadLibrary returned MSVCR80.dll not found.

I have compiled with USE_WIN_CRT_LIB comment out in nmake.opt

My application is a simple TiffOpen / TiffClose test, here is the relevant
code

    mh_DLLHandle: Cardinal;

DLL_TIFFOpen: function(const TiffFileName: string; const OpenMode: string): Pointer; stdcall;

DLL_TIFFGetField: function(TiffHandle: Pointer; Tag: LongInt; var Field): Cardinal; stdcall;

DLL_TIFFClose: procedure(TiffHandle: Pointer); stdcall;

DLL_TIFFSetErrorHandler: function(TIFFErrorProc: TDLL_TIFFError): longint; stdcall;

procedure TMainAppRunnerDlg.FormCreate(Sender: TObject);
begin
  mh_DLLHandle := LoadLibrary(PChar('libtiff.dll'));
  if mh_DLLHandle <> 0 then
  begin
    @DLL_TIFFOpen := GetProcAddress(mh_DLLHandle, 'TIFFOpen');
    if not Assigned(DLL_TIFFOpen) then
    begin
      OutputDebugString(PChar(Format('TIFFOpen not found:
%d',[GetLastError])));
      exit;
    end;

    @DLL_TIFFGetField := GetProcAddress(mh_DLLHandle, 'TIFFGetField');

    if not Assigned(DLL_TIFFGetField) then
    begin
      OutputDebugString(PChar(Format('DLL_TIFFGetField not found:
%d',[GetLastError])));
      exit;
    end;

    @DLL_TIFFClose := GetProcAddress(mh_DLLHandle, 'TIFFClose');
    if not Assigned(DLL_TIFFClose) then
    begin
      OutputDebugString(PChar(Format('DLL_TIFFClose not found:
%d',[GetLastError])));
      exit;
    end;

    @DLL_TIFFSetErrorHandler := GetProcAddress(mh_DLLHandle,
'TIFFSetErrorHandler');
    if not Assigned(DLL_TIFFSetErrorHandler) then
    begin
      OutputDebugString(PChar(Format('DLL_TIFFSetErrorHandler not found:
%d',[GetLastError])));
      exit;
    end;
  end
  else
  begin

OutputDebugString(PChar(Format('LoadLibrary failed: %d',[GetLastError])));

               exit;
            end;
          end;

procedure TMainAppRunnerDlg.FormDestroy(Sender: TObject);
begin
  FreeLibrary(mh_DLLHandle);
end;

procedure TMainAppRunnerDlg.btnTIFFOpenClick(Sender: TObject);
var

   lh_TiffHandle: Pointer;

begin
  lh_TiffHandle := DLL_TIFFOpen('C:\Develop\Tests\cheque_216_A.tif', 'r');
  try
  finally

               DLL_TIFFClose(lh_TiffHandle);

  end;
end;