Color components and endianess

Adam Goode agoode at andrew.cmu.edu
Fri Jun 11 14:32:12 EDT 2010


On 06/11/2010 08:16 AM, tom nygen wrote:
> Thank you for making OpenSlide available. It is very useful for me to
> deal effectively with multiple scanner manufacturers. I've just tried
> some examples and have the following questions:
> 

Glad it's working well for you!

> 1. There seems to be only one pixel data format retrieved from the
> slides and that is pre-multiplied ARGB. Since most of the slide formats
> (known to me) have no alpha channel, and if they do, RGB components are
> already pre-mulitplied with the alpha channel, why can't we use RGB
> (24-bit) instead of ARGB (32-bit) format when we get a region from the
> slide? This would ease integration for many people having codes handling
> 24-bit RGB format.
> 

In OpenSlide, we set the alpha channel to 0 when we are beyond the edge
of the slide. For some formats, including MIRAX, the alpha channel is
set to 0 where we don't have any data. I'm attaching an example PNG file
to illustrate this.


> 2. Since there could be an endian issue from one platform to the other,
> are there macros helping to make it easier to retrieve color components
> R, G, B from the 32-bit pixel data?
> 

Hmmm, there should be no endian issue here, the data is stored in native
endian format. This psuedo-code illustrates that:

 a = (pixel & 0xFF) >> 24
 r = (pixel & 0xFF) >> 16
 g = (pixel & 0xFF) >> 8
 b = pixel & 0xFF

Note that this means there is one 32-bit word per pixel, not four 8-bit
bytes.


Have fun with OpenSlide,

Adam
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alpha.png
Type: image/png
Size: 73943 bytes
Desc: not available
Url : http://lists.andrew.cmu.edu/pipermail/openslide-users/attachments/20100611/0062793f/attachment-0001.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
Url : http://lists.andrew.cmu.edu/pipermail/openslide-users/attachments/20100611/0062793f/attachment-0001.bin 


More information about the openslide-users mailing list