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
October 2005

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

2005.10.27 06:40 "How located pixels with BitsPerSample not bound to byte?", by Eugene Shebeko
2005.10.27 13:57 "Re: How located pixels with BitsPerSample not bound to byte?", by Frank Warmerdam
2005.10.28 03:18 "Re: How located pixels with BitsPerSample not bound to byte?", by David Mckenzie
2005.10.28 03:42 "Re: How located pixels with BitsPerSample not bound to byte?", by Frank Warmerdam
2005.10.28 04:08 "Re: How located pixels with BitsPerSample not bound to byte?", by Bob Friesenhahn
2005.10.28 04:21 "Re: How located pixels with BitsPerSample not bound to byte?", by Chris Cox
2005.11.07 19:18 "Re: How located pixels with BitsPerSample not bound to byte?", by Joris Van Damme
2005.11.07 20:26 "Re: How located pixels with BitsPerSample not bound to byte?", by Bob Friesenhahn
2005.11.09 05:00 "Re: How located pixels with BitsPerSample not bound to byte?", by Chris Cox
2005.11.13 18:05 "Re: How located pixels with BitsPerSample not bound to byte?", by Andrey Kiselev
2005.10.27 15:55 "Re: How located pixels with BitsPerSample not bound to byte?", by Bob Friesenhahn

2005.10.27 15:55 "Re: How located pixels with BitsPerSample not bound to byte?", by Bob Friesenhahn

> If we talking about testing exotic images.
>
> Look at the flower-rgb-contig-12.tif from the test images.
> It have RGB,Uncompressed, PlanarConfig=Continue, and
> BitsPerSample=12
>
> How the pixels are located inside a strip in such case?
> I really cann't understand :)
>
> Is it correct?
>
> Bytes:       0   |    1    |    2   |   3    |   4
> Bits :   76543210|7654|3210|76543210|76543210|7654|3210
> Pixels:  rrrrrrrr|rrrr|gggg|gggggggg|bbbbbbbb|bbbb|rrrr|
> Samples:   hiR   |lowR|hiG |  lowG  |  hiB   |lowB| hiR

I think that this is correct.

There is some code from GraphicsMagick which helps read/write samples 
from "bit streams".  The code can be obtained via the web from 
"http://cvs.graphicsmagick.org/cgi-bin/cvsweb.cgi/GraphicsMagick/magick/bit_stream.h".

The code is quite easy to use ('bytes' is a stream of bits such as a 
scanline):

   BitStreamReadHandle bit_stream;
   BitStreamInitializeRead(&bit_stream, bytes);

   Loop around code like this to collect all samples ...
     unsigned int red = BitStreamMSBRead(&bit_stream, 12);
     unsigned int green = BitStreamMSBRead(&bit_stream, 12);
     unsigned int blue = BitStreamMSBRead(&bit_stream, 12);

There is similar code to support writing bit streams.

The performance may not be as good as carefully hand-crafted code for 
a specific depth, but it makes dealing with depths ranging from 1 to 
32 bits very easy.  Since the code is inlined, if you can fill an 
array with red, green, blue and only invoke BitStreamMSBRead() once in 
the sample extraction loop (tighter loop), performance is likely to be 
better.

Bob
======================================
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/