I've got TIFF
with 256 byte color palette. In Java I read this TIFF
to BufferedImage
. This BufferedImage
has IndexColorModel
. When I iterate through pixels in BufferedImage
, I can only get RGB. I want to write method, which for x,y
gets original color index from palette using BufferedImage
(not RGB color, just original index from TIFF
s palette). How can I achieve that?
I know that I could iterate through IndexColorModel and check RBG equality, but it won't work if TIFF
has at least 2 indexes with the same colors (e.g. index 0 - black, 132 - black; suppose, that pixel 10x10 has black color [rgb=0,0,0]
- then I don't know which index should I take - they have the same RGB value).
I could also read raw TIFF
and then calculate pixel position in byte array, but I don't want to do this - I would like to use something from JAI
.
Is there any way to do this with BufferedImage
and JAI
without external libraries?
Thanks