AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
February 2007

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2007.02.06 03:31 "What's wrong with this program about adding a bitmap to TIFF file as Compression_JPEG ?", by <zhaoyj.flc@163.com>
2007.02.06 03:55 "What is wrong with the program about adding a Bitmap to a Tiff as Compression_JPEG ?", by <zhaoyj.flc@163.com>
2007.02.06 04:18 "Re: What is wrong with the program about adding a Bitmap to a Tiff as Compression_JPEG ?", by Joris Van Damme
2007.02.06 04:04 "Re: What's wrong with this program about adding a bitmap to TIFF file as Compression_JPEG ?", by Joris Van Damme

2007.02.06 04:04 "Re: What's wrong with this program about adding a bitmap to TIFF file as Compression_JPEG ?", by Joris Van Damme

Unknown name in non-ascii chars,

Unknown name in non-ascii chars wrote:
> procedure AddBitmapAsJpegtoTiff;

On the whole, your code looks reasonable, except for the following:

>  TIFFSetField(OpenTiff,TIFFTAG_COMPRESSION,COMPRESSION_JPEG);
>  TIFFSetField(OpenTiff,TIFFTAG_PHOTOMETRIC,PHOTOMETRIC_RGB);

Whilst the combination of JPEG compression and RGB photometric is perfectly 
legit on the TIFF level, it is badly supported. LibTiff may or may not be 
able to write it flawlessly (I suspect it will at least incorrectly add 
subsampling tags, but that shouldn't be too much of a problem), but very few 
readers are able to deal with it.

Use PHOTOMETRIC_YCBCR instead.

Of course, next you have to actually convert the color data to actual YCbCr 
before your call to TIFFWriteEncodedStrip.

> This code also has a problem,
> RowsPerStrip:=((256*1024) div (Bitmap.Width*3));if 256*1024 become
> a large number,there will be more than one strip in the IFD,but the
> data can't write ,only 1 KB after writing tothe TIFF .

Huh? 256*1024 is a constant, cannot 'become a large number', and I've never 
met data that can write - it's usually the code that does the writing.

This part of the code is fine. The rationale is, we aim at strips of about a 
quarter of a megabyte big, in their uncompressed form. So to approximate 
that, we make the div to find out how many lines make up that quarter of a 
megabyte. Next, we check and see if the result is either more then the image 
height, or less then 1, in either case we fix it up.

> How to add two bitmaps to one TIFF ,also
> as Compression_JPEG ?

That is documented on the LibTiff site.

If I remember correctly, you do need to make sure you've the latest version 
of LibTiffDelphi, as in some earlier versions I forgot to declare one 
function you need for this.


Best regards,

Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html