2006.04.15 10:46 "Re: [Tiff] LibTiffDelphi problem with WriteEncodedStrip Newbee", by Joris
> Try again. If it still doesn't work, mail me your zipped bitmap and > relevant code, and I'll take a look.
I've received your code and testfile, made sure I used the distributed version of LibTiffDelphi, and... Sure enough, I can reproduce your problem.
Apparently, you need to set the planar config tag, even though SamplesPerPixel equals 1. I can only assume this is no longer a requirement in my own LibTiffDelphi, and I thus didn't see the problem. It is a bit silly requirement anyway, probably it got removed at some later time.
As after inserting the line...
...before the setting of TIFFTAG_COMPRESSION, all is fine.
Since you had a problem, I was intriged by the fact that the proposed procedure didn't raise an exception. It was designed to do that, as is usual in Delphi code. The reason is, I got confused about error return value of TIFFWriteEncodedStrip (again!), and tested against 0 instead of -1.
One more thing I noticed in your own code, is that you write with G3 compression, instead of G4. There should be no advantage to G3 over G4, except for better error recovery in some situations that only possibly arise after corruption. But it's not as efficient. So I'd recommend you use G4 instead.
With these corrections in place, the code for writing a pf1bit Delphi TBitmap to a G4 compressed TIFF should be looking like this:
if (Bitmap.PixelFormat<>pf1bit) then
raise Exception.Create('WriteBitmapToTiff is designed for singlebit
RowSize:=((Bitmap.Width+7) div 8);
RowsPerStrip:=((256*1024) div RowSize);
Joris Van Damme
Download your free TIFF tag viewer for windows here: