Bug 691093 - Index Image processing
Summary: Index Image processing
Status: NOTIFIED WORKSFORME
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: General (show other bugs)
Version: 8.63
Hardware: PC Windows XP
: P2 normal
Assignee: Michael Vrhel
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-29 09:07 UTC by Tony Teveris
Modified: 2011-09-18 21:47 UTC (History)
0 users

See Also:
Customer: 400
Word Size: ---


Attachments
PDF contains indexed image (RGB(1,10,255)) (210.80 KB, application/pdf)
2010-01-29 09:09 UTC, Tony Teveris
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tony Teveris 2010-01-29 09:07:42 UTC
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
Comment 1 Tony Teveris 2010-01-29 09:09:29 UTC
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)
Comment 2 Henry Stiles 2010-01-29 14:14:47 UTC
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.
Comment 3 Ken Sharp 2010-01-30 00:58:17 UTC
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 '<'
Comment 4 Tony Teveris 2010-02-03 08:36:34 UTC
Ok, I'll take a look again and see what I find. What is the def of "hival"?


Comment 5 Ken Sharp 2010-02-03 08:47:43 UTC
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.
Comment 6 Tony Teveris 2010-02-03 11:22:31 UTC
Ok, I got it to work using the <=.

I also had a structure alignment problem with "bool" type.

All is well.

Thanks
Comment 7 Marcos H. Woehrmann 2011-09-18 21:47:11 UTC
Changing customer bugs that have been resolved more than a year ago to closed.