| AWARE [SYSTEMS] | Imaging expertise for the Delphi developer | |||||||
![]() |
TIFF and LibTiff Mailing List Archive | |||||||
LibTiff Mailing List
TIFF and LibTiff Mailing List Archive Contact
The TIFF Mailing List Homepage |
Thread2009.11.02 23:02 "Re: Tiffcrop test suite and logluv issues", by Toby ThainOn 2-Nov-09, at 4:59 PM, Richard Nolde wrote:
> ...
> Every pixel shows at least one change for sample 0, a few pixels show
> multiple changes. Since tiffcp doesn't do anything but copy
> scanlines,
> unlike tiffcrop which loads the image into memory so that it can be
> manipulated, it is hard to figure out why the data would change
> unless,
> as I suspect, the following code from tif_luv.c doesn't take into
> consideration the fact that the original data is bigendian and I am
> compiling on a little endian host (having just gone through this with
> Toby's patch suggestion.) In fact, running tiffcp or tiffcrop with
> the
> -B switch to generate big endian TIFF produces quite a different
> result
> for both off_luv24.tif and off_luv32.tif.
>
> LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
> {
> LogLuvState* sp = DecoderState(tif);
> int cc, i, npixels;
> unsigned char* bp;
> uint32* tp;
>
> assert(s == 0);
> assert(sp != NULL);
>
> npixels = occ / sp->pixel_size;
>
> if (sp->user_datafmt == SGILOGDATAFMT_RAW)
> tp = (uint32 *)op;
> else {
> assert(sp->tbuflen >= npixels);
> tp = (uint32 *) sp->tbuf;
> }
> /* copy to array of uint32 */
> bp = (unsigned char*) tif->tif_rawcp;
> cc = tif->tif_rawcc;
> for (i = 0; i < npixels && cc > 0; i++) {
> tp[i] = bp[0] << 16 | bp[1] << 8 | bp[2];
^^ This is a portable way of decoding a 3-byte BigEndian value. It
will work on any host.
--Toby
> bp += 3;
> cc -= 3;
> }
>
> Richard Nolde
>
> _______________________________________________
> Tiff mailing list: Tiff@lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/tiff
> http://www.remotesensing.org/libtiff/
|
|||||||