I'm trying to deal with 16-bits per channel RGBA TIFF images through C language, I could not find a lot of information about 16-bits images in the specifications.
In case of a 8-bits per channel RGBA image, I understand that a pixel is stored as a uint32, and can be deinterlaced by grouping the 32 bits into 4 groups (R,G,B,A) of 8 bits. Then to deal with 8-bits per channel RGBA images, I'm doing the following (see also enclosed source code here):
- I store the image data as a uint32 tab (using TIFFReadRGBAImageOriented) that I call
data_tiff
- I deinterlace pixels using the following commands:
(uint8) TIFFGetR(*data_tiff)
,(uint8) TIFFGetG(*data_tiff)
,(uint8) TIFFGetB(*data_tiff)
&(uint8) TIFFGetA(*data_tiff)
In case of a 16 bits per channel RGBA image, could you tell me how can I deinterlace pixels? if I could retreive image data as a uint64 tab, then I could do the following:
#define TIFF16GetR(abgr) ((abgr) & 0xffff)
#define TIFF16GetG(abgr) (((abgr) >> 16) & 0xffff)
#define TIFF16GetB(abgr) (((abgr) >> 32) & 0xffff)
#define TIFF16GetA(abgr) (((abgr) >> 48) & 0xffff)`
- I read the image data as a uint64 tab
- I deinterlace pixels using
(uint16) TIFF16GetR(*data_tiff)
,(uint16) TIFF16GetG(*data_tiff)
,(uint16) TIFF16GetB(*data_tiff)
&(uint16) TIFF16GetA(*data_tiff)
but it seems that data are not natively stored in a uint64 tab, so I wonder how are interlaced 16-bits per channel images into a uint32 pixel tab.
I'm also facing difficulties dealing with 16-bits grayscaled images in the same way (using TIFFReadRGBAImageOriented
to get image data and trying to convert each pixel into a uint16)
More generally, do you have any piece of documentation about 16 bits grayscale and color images?
Thank you, Best Regards,
Rémy A.