Indexed Color Images Within my begin image I would like to determine that the image data is indexed, how many indexes are used and the color components. I’m attempting to do this for simple RGB images. I currently do the following: bi.bIsIndexed = FALSE; if (pcs && pcs->type->index == gs_color_space_index_Indexed) { int i; bi.bIsIndexed = TRUE; for (i=0; i < pcs->params.indexed.hival; i++) { bi.rgbT[i].rgbtRed = ppi->ColorSpace- >params.indexed.lookup.table.data[i*3]; bi.rgbT[i].rgbtGreen = ppi->ColorSpace- >params.indexed.lookup.table.data[i*3+1]; bi.rgbT[i].rgbtBlue = ppi->ColorSpace- >params.indexed.lookup.table.data[i*3+2]; } } In the case of the file I’m processing (attached – BlueBox 1,10,255.pdf) the hival is 0. Any help is appreciated Thanks
Created attachment 5915 [details] PDF contains indexed image (RGB(1,10,255)) PDF contain an indexed image RGB, the Blue is RGB(1,10,255)
I didn't actually look at your file but I see something wrong with the indexing. hival is the last index. For example hival == 255 for a table size of 256 so the for loop would never process the last element in the table data.
The colour space contains one colour, so hival (as Henry says, the highest colour value) is 0, because the index starts at 0. 11 0 obj [/Indexed /DeviceRGB 0 16 0 R] endobj As you can see, the hival entry has a value of 0. Seems to me the loop should have a '<=' not '<'
Ok, I'll take a look again and see what I find. What is the def of "hival"?
From the 3rd Edition PostScript Language Reference Manual, p239: "An Indexed color space is selected as follows: [/Indexed base hival lookup] setcolorspace .... .... The hival parameter is an integer that specifies the maximum valid index value. In other words, the color table is to be indexed by integers in the range 0 to hival. hival can be no greater than 4095, which is what would be required to index a table with 12-bit color sample values. " Very similar text can be found in the PDF Reference Manual. In my edition on p262: "An Indexed color space is defined by a four-element array: [ /Indexed base hival lookup ] ... ... The hival parameter is an integer that specifies the maximum valid index value. In other words, the color table is to be indexed by integers in the range 0 to hival. hival can be no greater than 255, which is the integer required to index a table with 8-bit index values. " Notice that in PDF only 8-bit index values are permitted, unlike PostScript which permits up to 12.
Ok, I got it to work using the <=. I also had a structure alignment problem with "bool" type. All is well. Thanks
Changing customer bugs that have been resolved more than a year ago to closed.