Re: Pixmap problem [message #45314 is a reply to message #36253] |
Tue, 30 August 2005 11:39  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
MA writes:
> I'm trying to solve a problem using a pixmap image and would be
> grateful for some advice. I have a plot with ~5500 irregular boxes
> (POLYFILL plot). I want to make the plot clickable, so I can retrieve
> and alter the information associated with each of the boxes. I'd like
> to use a pixmap as a lookup table in which to save a unique index for
> each box. On clicking the plot, I should then be able to find the index
> corresponding to the clicked box by looking at the same pixel in the
> pixmap.
> My problem is the following: I have ~ 5500 boxes (indeces), but
> POLYFILL only accepts color tables (8 bits - maximum of 256 unique
> indeces), or so it seems. Is there any way to get my pixmap image to be
> in 24 bit color, so I can use 3x8 bits to construct my indeces from?
> The 'TrueColor' keyword in 'device, COPY...' should then allow me to
> retrieve the 2x8 bit information. I've been playing around a bit with
> the decomposed setting, but without much luck.
Here is what I would do. I wouldn't use a pixmap. I would
use an integer array the same size as your window:
selectArr = IntArr(!D.X_Size, !D.Y_Size)
I would load your selection array with your polygon "numbers"
like this:
s = Size(selectArr, /Dimensions)
FOR j=0L, NPOLYGONS-1 DO
indices = PolyFillV(xpoly[j], ypoly[j], s[0], s[1])
selectArr[indices] = j
ENDFOR
Then, to find the polygon number, take your location in the
display window and directly access your selection array:
polygonNumber = selectArr[event.x, event.y]
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|