Author Topic: libtiffdelphi 3.9.1  (Read 20249 times)

Offline nomas

  • Imaging User
  • *
  • Posts: 23
    • View Profile
libtiffdelphi 3.9.1
« on: 1 September 2009, 18:24:07 »
It's libtiff 3.9.1 implementation for imaginglib.

But it's not fully tested.

http://www.vdebris.comli.com/wp-content/uploads/2009/09/libtiffdelphi_3_9_1.rar

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 361
    • View Profile
    • Galfar's Homepage
Re: libtiffdelphi 3.9.1
« Reply #1 on: 1 September 2009, 19:44:05 »
Thanks, I tested it on TIFF test images I've got and no errors were found.
I'll include this to Imaging 0.26.4.

Offline rubypdf

  • Imaging User
  • *
  • Posts: 9
    • View Profile
Re: libtiffdelphi 3.9.1
« Reply #2 on: 11 September 2009, 07:22:30 »
when does libtiffdelphi support FPC?
I successfully compiled tiff-3.9.1 and tiff-4.0.0beta4 by using GCC, but seems the modification of LibTiffDelphi.pas is still a big job.

btw, I can not include jbig support in LibTiff, I do not know why.

Offline rubypdf

  • Imaging User
  • *
  • Posts: 9
    • View Profile
Re: libtiffdelphi 3.9.1
« Reply #3 on: 13 September 2009, 10:58:20 »
successfully compiled imaginglib with tiff support, but failed to install, got the following message:

C:\lazarus\ide\lazarus.pp(132,1) Error: Undefined symbol: _read
C:\lazarus\ide\lazarus.pp(132,1) Error: Undefined symbol: _write
C:\lazarus\ide\lazarus.pp(132,1) Error: Undefined symbol: _lseek
C:\lazarus\ide\lazarus.pp(132,1) Error: Undefined symbol: _fstat
C:\lazarus\ide\lazarus.pp(132,1) Error: Undefined symbol: _open
C:\lazarus\ide\lazarus.pp(132,1) Error: Undefined symbol: _close
C:\lazarus\ide\lazarus.pp(132,1) Error: Undefined symbol: _lfind
C:\lazarus\ide\lazarus.pp(132,1) Fatal: There were 7 errors compiling module, stopping

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 361
    • View Profile
    • Galfar's Homepage
Re: libtiffdelphi 3.9.1
« Reply #4 on: 14 September 2009, 15:03:58 »
These are C RTL functions which need to be linked to executable created by FPC. Some RTL functions are defined in LibDelphi.pas and LibTiffDelphi.pas but looks like these few aren't there.

You'll have to implement them on Pascal side too, or link to CRT library.

Linking to CRT is probably easier (I use this in OpenJpeg):
1) In Extras/J2KObjects is libcrtdll.a static library
2) Put {$linklib libcrtdll.a} somewhere to your Pascal code (LibTiffDelphi.pas)
3) Make sure libcrtdll.a is in FPC's library search path

Hmm do you have JPEG 2000 (OpenJpeg) support enabled in Imaging? If you do, then libcrtdll.a should already be linked to your exe.

I see you're installing Imaging as Lazarus package, what happens if you just use it in normal application? The same linking error?

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 361
    • View Profile
    • Galfar's Homepage
Re: libtiffdelphi 3.9.1
« Reply #5 on: 14 September 2009, 15:05:34 »
It's libtiff 3.9.1 implementation for imaginglib.

But it's not fully tested.

http://www.vdebris.comli.com/wp-content/uploads/2009/09/libtiffdelphi_3_9_1.rar

Nomas, have you included the changes made by Aware to libtiff on C side in original LibTiffDelphi sources, or it just works without them too?

Offline rubypdf

  • Imaging User
  • *
  • Posts: 9
    • View Profile
Re: libtiffdelphi 3.9.1
« Reply #6 on: 14 September 2009, 18:56:45 »
These are C RTL functions which need to be linked to executable created by FPC. Some RTL functions are defined in LibDelphi.pas and LibTiffDelphi.pas but looks like these few aren't there.

You'll have to implement them on Pascal side too, or link to CRT library.

Linking to CRT is probably easier (I use this in OpenJpeg):
1) In Extras/J2KObjects is libcrtdll.a static library
2) Put {$linklib libcrtdll.a} somewhere to your Pascal code (LibTiffDelphi.pas)
3) Make sure libcrtdll.a is in FPC's library search path

Hmm do you have JPEG 2000 (OpenJpeg) support enabled in Imaging? If you do, then libcrtdll.a should already be linked to your exe.

I see you're installing Imaging as Lazarus package, what happens if you just use it in normal application? The same linking error?

Yes, the same linking error when I use it in normal application.
and I use Jpeg2000 you release too, if just use Jpeg2000, it works well.
I also put {$linklib libcrtdll.a} into libtiffdelphi.pas,zlibdelphi.pas and libjpegdelphi.pas again.



Offline rubypdf

  • Imaging User
  • *
  • Posts: 9
    • View Profile
Re: libtiffdelphi 3.9.1
« Reply #7 on: 14 September 2009, 21:15:36 »
successfully install it now, and it need
{$Linklib libmoldname} 
and successfully compile LCLImager and VampConvert, both support tiff read/write now.
it does not support attachment here, so I upload it to my blog website,

VampConvert.zip
LCLImager.zip
I think the exe is clean, and you had better to scan it before using.

I am a beginner of delphi and freepascal, and I need some time to clean source code, so no source code to download now, but if you want to help me to clean the source code, please let me know, and I give you source code and tell you how to compile it


« Last Edit: 15 September 2009, 03:02:15 by Galfar »

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 361
    • View Profile
    • Galfar's Homepage
Re: libtiffdelphi 3.9.1
« Reply #8 on: 15 September 2009, 02:48:58 »
Good work,

I tested LCLImager you sent on various TIFFs, it works for all TIFF types I have except TIFFs that use JPEG compression. I get assertion failure in tiff_jpeg.c for these (see attached image).

Quote
..., but if you want to help me to clean the source code, please let me know, and I give you source code and tell you how to compile it
Sure, send the code.

Quote
it does not support attachment here
It should work now, I moved the site to new hosting recently and there are still some issues from time to time.

Btw, have you made any modifications to libtiff C sources to get it linking/working with FPC?

Offline rubypdf

  • Imaging User
  • *
  • Posts: 9
    • View Profile
Re: libtiffdelphi 3.9.1
« Reply #9 on: 15 September 2009, 11:53:43 »
no, I did no modification, maybe I am not link the libjpeg correctly, so it does not support jpeg, I compile it again today, support jpeg, but popup other issues.

download the source code of libzlib1.2.3, libjpeg6b, libtiff 3.9.1
compiled them under gcc 4.2+msys, and got libz.a, libjpeg.a, libtiff.a

modified zlibdelphi.pas, libjpegdelphi.pas and libdelphi.pas(learned from jpeg2000 for pascal)

To successfully compile and install, we need link more libraries,
{$linklib libmoldname}//to solve the issues I mentioned above
{$Linklib libmsvcrt}//libmsvcrt seems need libmsvcrtd.a
{$Linklib libkernel32}
{$Linklib libcrtdll} 
{$Linklib libjpeg} //seems this one need to be linked again, or does not support jpeg compressed tiff.
{$Linklib libz}

I put them in ImagingExtras.pas, or we have to put them in lazarus.pas and the project we compile, I do not know why.


I tried LibTiff4.0b3, but does not work.

Still clean the code.

Offline rubypdf

  • Imaging User
  • *
  • Posts: 9
    • View Profile
Re: libtiffdelphi 3.9.1
« Reply #10 on: 15 September 2009, 20:48:24 »
libtiff 4.0 beta4 and jpeg-7 also works.
lclImager does not support the attched 3 tiff(uncompressed and old jpeg)
I am not test if delphi version support them or not, I am afraid it does not support either, because of the bug of imagingtiff.pas.

 but I notice the imagingtiff only support 5 compress schemes, and the value seems also incorrect,
Quote
Specifies compression scheme used when saving TIFF images. Supported values
      are 0 (Uncompressed), 1 (LZW), 2 (PackBits RLE), 3 (Deflate - ZLib), 4 (JPEG).
      Default is 1 (LZW). Note that not all images can be stored with
      JPEG compression - these images will be saved with default compression if
      JPEG is set.

but libtiff support the following compress schemes,

Quote
    COMPRESSION_NONE                    = 1;     { dump mode }
    COMPRESSION_CCITTRLE                = 2;     { CCITT modified Huffman RLE }
    COMPRESSION_CCITTFAX3               = 3;     { CCITT Group 3 fax encoding }
    COMPRESSION_CCITT_T4                = 3;       { CCITT T.4 (TIFF 6 name) }
    COMPRESSION_CCITTFAX4           = 4;      { CCITT Group 4 fax encoding }
    COMPRESSION_CCITT_T6                = 4;       { CCITT T.6 (TIFF 6 name) }
    COMPRESSION_LZW              = 5;       { Lempel-Ziv  & Welch }
    COMPRESSION_OJPEG              = 6;      { !6.0 JPEG }
    COMPRESSION_JPEG              = 7;      { %JPEG DCT compression }
    COMPRESSION_NEXT              = 32766;   { NeXT 2-bit RLE }
    COMPRESSION_CCITTRLEW           = 32771;   { #1 w/ word alignment }
    COMPRESSION_PACKBITS           = 32773;   { Macintosh RLE }
    COMPRESSION_THUNDERSCAN           = 32809;   { ThunderScan RLE }
    { codes 32895-32898 are reserved for ANSI IT8 TIFF/IT <dkelly@apago.com) }
    COMPRESSION_IT8CTPAD           = 32895;   { IT8 CT w/padding }
    COMPRESSION_IT8LW              = 32896;   { IT8 Linework RLE }
    COMPRESSION_IT8MP              = 32897;   { IT8 Monochrome picture }
    COMPRESSION_IT8BL              = 32898;   { IT8 Binary line art }
    { compression codes 32908-32911 are reserved for Pixar }
    COMPRESSION_PIXARFILM           = 32908;   { Pixar companded 10bit LZW }
    COMPRESSION_PIXARLOG           = 32909;   { Pixar companded 11bit ZIP }
    COMPRESSION_DEFLATE              = 32946;   { Deflate compression }
    COMPRESSION_ADOBE_DEFLATE           = 8;       { Deflate compression, as recognized by Adobe }
    { compression code 32947 is reserved for Oceana Matrix <dev@oceana.com> }
    COMPRESSION_DCS                     = 32947;   { Kodak DCS encoding }
    COMPRESSION_JBIG              = 34661;   { ISO JBIG }
    COMPRESSION_SGILOG              = 34676;   { SGI Log Luminance RLE }
    COMPRESSION_SGILOG24           = 34677;   { SGI Log 24-bit packed }
    COMPRESSION_JP2000                  = 34712;   { Leadtools JPEG2000 }

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 361
    • View Profile
    • Galfar's Homepage
Re: libtiffdelphi 3.9.1
« Reply #11 on: 16 September 2009, 00:08:30 »
These TIFFs are not loaded properly by Delphi version either (but some editors/viewers won't open them too, especially old-jpeg one).

But it's not caused by compression scheme settings - these are used only in saving and they are correctly translated to COMPRESSION_xxx constants.
See
Code: [Select]
Compressions: array[0..4] of Word = (COMPRESSION_NONE, COMPRESSION_LZW,
    COMPRESSION_PACKBITS, COMPRESSION_DEFLATE, COMPRESSION_JPEG);
in ImagingTiff.pas around line 336. I could add some more compression options there.

I see there's COMPRESSION_JP2000, do you happen to know which JPEG2000 library is used by libtiff for this (if any)?


Offline rubypdf

  • Imaging User
  • *
  • Posts: 9
    • View Profile
Re: libtiffdelphi 3.9.1
« Reply #12 on: 16 September 2009, 02:00:21 »
have no idea about Compress_JP2000
seems freeimage support the attached images, I need confirm, but I know InfranView(also developed in delphi) support it,



http://www.ece.uvic.ca/~mdadams/jasper/

Offline nomas

  • Imaging User
  • *
  • Posts: 23
    • View Profile
Re: libtiffdelphi 3.9.1
« Reply #13 on: 23 September 2009, 02:24:17 »
It's libtiff 3.9.1 implementation for imaginglib.

But it's not fully tested.

http://www.vdebris.comli.com/wp-content/uploads/2009/09/libtiffdelphi_3_9_1.rar

Nomas, have you included the changes made by Aware to libtiff on C side in original LibTiffDelphi sources, or it just works without them too?


I had many changes in tif_jpeg.c and some changes on other files.

Offline rubypdf

  • Imaging User
  • *
  • Posts: 9
    • View Profile
Re: libtiffdelphi 3.9.1
« Reply #14 on: 24 September 2009, 02:27:35 »
It's libtiff 3.9.1 implementation for imaginglib.

But it's not fully tested.

http://www.vdebris.comli.com/wp-content/uploads/2009/09/libtiffdelphi_3_9_1.rar

Nomas, have you included the changes made by Aware to libtiff on C side in original LibTiffDelphi sources, or it just works without them too?


I had many changes in tif_jpeg.c and some changes on other files.

I got many errors when I compiled it under GCC
Code: [Select]
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:442: undefined reference to `TIFFcallvjpeg_jpeg_destroy'
.libs/tif_jpeg.o: In function `JPEGEncode':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:345: undefined reference to `TIFFcalljpeg_jpeg_write_scanlines'
.libs/tif_jpeg.o: In function `TIFFjpeg_write_raw_data':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:356: undefined reference to `TIFFcalljpeg_jpeg_write_raw_data'
.libs/tif_jpeg.o: In function `TIFFjpeg_set_colorspace':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:306: undefined reference to `TIFFcallvjpeg_jpeg_set_colorspace'
.libs/tif_jpeg.o: In function `TIFFjpeg_set_quality':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:316: undefined reference to `TIFFcallvjpeg_jpeg_set_quality'
.libs/tif_jpeg.o: In function `TIFFjpeg_error_exit':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:235: undefined reference to `TIFFjpeg_error_exit_raise'
.libs/tif_jpeg.o: In function `JPEGInitializeLibJPEG':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:288: undefined reference to `TIFFcallvjpeg_jpeg_CreateDecompress'
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:274: undefined reference to `TIFFcallvjpeg_jpeg_CreateCompress'
.libs/tif_jpeg.o: In function `JPEGSetupEncode':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:297: undefined reference to `TIFFcallvjpeg_jpeg_set_defaults'
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:325: undefined reference to `TIFFcallvjpeg_jpeg_suppress_tables'
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:375: undefined reference to `TIFFcallvjpeg_jpeg_write_tables'
.libs/tif_jpeg.o: In function `TIFFjpeg_read_scanlines':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:403: undefined reference to `TIFFcalljpeg_jpeg_read_scanlines'
.libs/tif_jpeg.o: In function `TIFFjpeg_finish_decompress':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:424: undefined reference to `TIFFcalljpeg_jpeg_finish_decompress'
.libs/tif_jpeg.o: In function `TIFFjpeg_read_header':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:384: undefined reference to `TIFFcalljpeg_jpeg_read_header'
.libs/tif_jpeg.o: In function `JPEGDecodeRaw':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:414: undefined reference to `TIFFcalljpeg_jpeg_read_raw_data'
.libs/tif_jpeg.o: In function `TIFFjpeg_alloc_sarray':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:453: undefined reference to `TIFFcalljpeg_alloc_sarray'
.libs/tif_jpeg.o: In function `JPEGPreEncode':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:335: undefined reference to `TIFFcallvjpeg_jpeg_start_compress'
.libs/tif_jpeg.o: In function `JPEGPreDecode':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:433: undefined reference to `TIFFcallvjpeg_jpeg_abort'
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:393: undefined reference to `TIFFcallvjpeg_jpeg_start_decompress'
.libs/tif_jpeg.o: In function `JPEGPostEncode':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_jpeg.c:366: undefined reference to `TIFFcallvjpeg_jpeg_finish_compress'
.libs/tif_ojpeg.o: In function `OJPEGDecode':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_ojpeg.c:785: undefined reference to `jpeg_read_raw_data_encap'
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_ojpeg.c:831: undefined reference to `jpeg_read_scanlines_encap'
.libs/tif_ojpeg.o: In function `OJPEGPreDecode':
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_ojpeg.c:1115: undefined reference to `jpeg_create_decompress_encap'
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_ojpeg.c:1125: undefined reference to `jpeg_read_header_encap'
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_ojpeg.c:1183: undefined reference to `jpeg_start_decompress_encap'
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_ojpeg.c:705: undefined reference to `jpeg_read_raw_data_encap'
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_ojpeg.c:735: undefined reference to `jpeg_read_scanlines_encap'
f:/2009/tiff/gcc/imaginglib_tiff-3.9.1/libtiff/tif_ojpeg.c:711: undefined reference to `jpeg_read_raw_data_encap'
.libs/tif_ojpeg.o: In function `OJPEGLibjpegJpegSourceMgrResyncToRestart':
...