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
March 1994

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

1994.03.31 10:31 "A little PackBits bug", by Roland Nahser
1994.03.31 19:30 "Re: A little PackBits bug", by Dan Mccoy

1994.03.31 19:30 "Re: A little PackBits bug", by Dan Mccoy

You pointed out the bug in 3.3 packbits code:

>         if (n == 1 && -op[-2] == 1 && ...

back in 3.2, op was declared "char" and the test read:

>          if (n == 1 && op[-2] == (char)-1 && ...

which was a little better. 
Updating the (char) to (tidata_t) would probably have worked better
than the changes introduced in 3.3.

>I think the most portable way is to test: op[-2] == 255.
> ...
>The solution: - (char)op[-2] == 1 works on machines where 
>char is signed char. 

How about the solution: op[-2] == (tidata_t) -1 

>Second I am using a "private" TIFF-format for temporary storing 
>images generated by our GKS-software in the following format
>Separate planes

Here's your problem, separate planes.
If you use LZW for separate planes, you have to write all of each
plane before moving on to the next plane.

Personally, I'm fond of contiguous planes.

>TIFFWriteScanline:Compression algorithm does not support random access 

>I am writing the image with the following simplified code fragment :

>    for (i = 0; i < numscans; i++) {
>      /* small loop over planes (or) samples */
>      for (sample = 0; sample < samperpix; sample++ ) {
>        /* start byte in data stream = startdata */
>        startdata = (char *) &data[iofp] + startbyte;
>         (void) TIFFWriteScanline(out, (tdata_t) startdata, tmprow, 
>                                  (tsample_t) sample);
>        iofp += planelen;
>      } /* end loop over samples */
>    } /* end loop over scans */

I do not understand why this is direct access. 
Because when rowsperstrip > 1, it wants to buffer two strips of
plane 0 before it can move on to plane 1.

The easiest way to get your code working would be to reorder your loops 
(you may have to fix up the buffer indexing):

    /* small loop over planes (or) samples */
    for (sample = 0; sample < samperpix; sample++ ) {
       for (i = 0; i < numscans; i++) {
        /* start byte in data stream = startdata */
        startdata = (char *) &data[iofp] + startbyte;
         (void) TIFFWriteScanline(out, (tdata_t) startdata, tmprow, 
                                  (tsample_t) sample);
        iofp += planelen;
      } /* end loop over scans */
    } /* end loop over samples */

I hope that helps,

Dan McCoy	Pixar		mccoy@pixar.com