java - Convert 8-bit Indexed color to RGB -
i cannot find conversion routine converting 8-bit indexed color rgb. background details, using poi read xlsx file , 1 of cells has background color indexed value 64. when attempt create pdfpcell in itext value background basecolor, navy blue , correct color should black. need routine convert value of 64 rgb(0, 0, 0).
this code sets background navy blue
short c = ((xssfcolor) color).getindexed(); basecolor base = new basecolor(c);
i found similar question here on "packed" routine failed "color value outside range 0-255".
short packed = ((xssfcolor) color).getindexed(); log.debug("indexed {}", packed); int r = (packed >> 5) * 32; int g = ((packed >> 2) << 3) * 32; int b = (packed << 6) * 64; basecolor base = new basecolor(r, g, b);
update 1: seems there palette somewhere in document, in case xssfpalette. once find answer i'll update here.
update 2: xssfworkbook doesn't provide access palette, hence follow question: access color palette in xssfworkbook
there isn't mathematical relationship between color index , rgb values. it's lookup.
eight-bit indexed color means each pixel's color represented number 0-255. colors depends on pallette (just painter use!) 8 bits, therefore, allow have 256 separate colors in picture.
if image displays in color, have pallette somewhere tell index corresponds rgb triplet.
Comments
Post a Comment