[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: point-in-pict-p



In article <geek-2401951105410001@gray.covis.nwu.edu>, geek@nwu.edu (Joey
Gray) wrote:

|In article <lynch-1701950000480001@129.105.100.156>, lynch@ils.nwu.edu
|(Richard Lynch) wrote:
|
|> Given a pict that was formed with, say:
|> 
|> ;untested code...
|> (#_OpenPict ...)
|> (#_PenSize 5 5)
|> (#_PenMode #$srcOr)
|> (rlet ((rect :topleft #@(10 10) :botright #@(50 50)))
|>   (#_FrameRect rect))
|> (setq pict (#_ClosePict))
|> 
|> I need a function that will return non-NIL for those pixels actually
|> covered by the rectangle, but NIL for those points inside the rectangle.
|> 
|> ie, (point-in-pict-p pict #@(12 12)) --> T [or any non-NIL]
|>     (point-in-pict-p pict #@(24 24)) --> NIL
|> 
|> Is there some easy way to do this?
|> 
|> -- "TANSTAAFL"  Rich lynch@ils.nwu.edu
|
|rich,
|
|to do it *right* you would need to know the "mask" for the picture being
|drawn, that is all of the bits in the picture's rectangle that would
|change were the picture drawn. okay, i know that's not *exactly* what the
|mask is, but let's go on anyway. that mask would probably exist as a
|region or a bitmap (which you can convert to a region), and then checking
|if a point is in a region is easy: (#_PtInRgn point region)
|
|however, i don't know of any easy way to get the mask. if you can assume
|the following, you can do sort of a skanky thing:
|
|1 - the background over which the picture is drawn is of a solid, uniform color
|2 - everything drawn as part of the picture actually changes the pixel's
|    appearance (either color or b/w)
|
|in other words, let me explain by example. suppose we have a window with a
|solid gray background. now we draw the picture in question which is the
|rectangle picture you described above. given a point to check, we can do
|the following: get the pixel value at the point in question (color or b/w)
|and compare that to the background pixel value. if they're not the same,
|you hit the picture; if equal, you missed the picture.
|
|like i said, that's pretty skanky, but given your situation it may work. i
|don't know of any easy way to determine whether a given pixel is actually
|part of a picture or not. the picture utility stuff that came with system
|7 doesn't even seem to include anything that you can use for this.

Actually, I tried something like that using an offscreen window to paint
it black, drawPicture, test the pixel, paint it white, drawpicture test
the pixel, and if it was black the first time and white the second, the
PICT must have been clear.  Unfortunately, since the window was offscreen,
no real drawing was done, so testing pixel colors returned random values.
:-(

I could probably go to a gworld or something like that [assuming that the
offscreen drawing of gworlds does what I think it does], but that's
getting really skanky for something that should be so simple...

There's Calc[C]Mask that's kinda like what I want, except takes a bitmap
as input, and I've got a PICT and to make that a bitmap means I gotta draw
it in a window [right?] and I'll need to do this offscreen so...

-- 
-- 
--
-- "TANSTAAFL"  Rich lynch@ils.nwu.edu