[comp.windows.news] problem with color maps, rasterfiles & imagecanvas in OW 1.0.1

kneller@socrates.ucsf.edu (Don Kneller) (05/08/90)

(Note: This was actually a problem in OW 1.0 as well)


PROBLEM SUMMARY:
----------------

*Some* 8-bit indices in rasterfiles seem to "mutate" to other indices when
displayed with imagecanvas.



BACKGROUND:
-----------

I'm using the NeWS imagecanvas procedure to image a rasterfile onto a
canvas. The rasterfile is created from a data set which is about 2K X
2K floats in size. The rasterfile is the same size and contains no
color map information (ras_type == RT_STANDARD, ras_maptype ==
RMT_NONE). The rasterfile has the usual raster.h header, the data, and
some additional information tacked onto the end to tell my program
the encoding between data and 8-bit colormap index.

Before using imagecanvas to image the data, a colorsegment is created:

	{ get PSEUDOCOLOR visual from framebuffer /VisualList }	% visual
	createcolormap					% colormap
	/colormap 1 index store				% colormap
	/Visual 1 index send				% colormap visual
	/Size exch send					% colormap size
	0						% colormap size 0
	createcolorsegment				% colorsegment
	/colorseg exch store				% -

The colorsegment is filled in with the desired colors:

	/addcolormapentry {	% color ndx => -
		colorseg exch get		% color colormapentry
		dup /Slot get			% color colormapentry slot
		3 -1 roll			% colormapentry slot color
		putcolor			% -
	} def

And the color map is installed:

	  /installcolormap {	% bool => -
		colormap begin
			dup Installed ne {		% bool
				  /Installed exch def	% -
			}{				% bool
				pop			% -
			} ifelse
		end
	  } def



PROBLEM:
--------

The problem I'm having is that *some* of the rasterfile colormap
indices seem to "mutate" to other values when displayed with
imagecanvas. For example, an index that is 8 in the rasterfile somehow
has the index 254 when displayed with imagecanvas. For each rasterfile,
only one index seems to be mutated and the index which is mutated isn't
always the same, but it is always a small integer like 8 or 16 and it
always gets mutated to a large integer like 254 or 255.

I've examined the colormap and it looks fine. Changing the colorsegment
entry for index 254 does in fact change the color of the on-screen
display where the rasterfile had an index of 8.



HELP:
-----

Any help would be appreciated.
-----
	Don Kneller
UUCP:		...ucbvax!ucsfcgl!kneller
INTERNET:	kneller@cgl.ucsf.edu
BITNET:		kneller@ucsfcgl.BITNET