[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2045.0. "How to determine pixel value ?" by WPOMM2::ZAMBOTTI () Tue Jan 16 1990 03:47

Hi,

whats the xlib (not xtoolkit) function to determine the pixel value of a point
at position x,y within a drawable?

Walter Zambotti.
T.RTitleUserPersonal
Name
DateLines
2045.1easyFEGPX::SWEENEYPatrick Sweeney in Hong KongTue Jan 16 1990 10:145
    As you have phrased the question, the answer is "there is no function".
    
    The superficial answer is "use XGetPixel", but the deeper answer is that
    for windows, the pixel value can only be obtained when is the pixel is
    viewable.  For pixmaps, the pixel value is returned.
2045.2But not that easy!EXLIB::DLUGOSZOpen foot, Insert MouthTue Jan 16 1990 10:4619
    XGetPixel can't be used to directly access a window or pixmap. It's
    definition is:
    	
    	unsigned long XGetPixel(ximage, x, y)
    	    XImage *ximage;
    	    int x, y;
    
    Know way to pas the pointer to the display or a resource id for
    the drawable in question. 
    
    This routine is used with images (which are client side and explains
    the lack of the above mentioned parameters). So before you use it
    you must capture an image of the drawable (or part of it) using
    XGetImage().
    
    I don't know of any way to directly access a pixel in a drawable,
    but sure wish that there was one!
    
    Ron
2045.3From the depressed individual sitting on the window sill !!!WPOMM2::ZAMBOTTITue Jan 16 1990 20:2413
Sound great so far guys...

What an oversight.

I'm trying to implement a flood routine and require to know the value of each
pixel as the flood area is been traversed.  Creating an image of each pixel
sounds awful slow to me guys.  Looks like I'll have to make an image of the
entire window and manipulate the image then put it back when the flood is
finished.

Buy buy cruel world...

Walter.
2045.4Yeah, I have to do the same thing.EXLIB::DLUGOSZOpen foot, Insert MouthWed Jan 17 1990 09:388
    I need to implement the same type of feature for my program. That's
    the only way I've figured out for doing it. Just haven't gotten
    around to implementing it yet.
    
    If you find some better way let me know!
    
    
    Ron
2045.5works for meFEGPX::SWEENEYPatrick Sweeney in Hong KongWed Jan 17 1990 09:517
    You XGetImage an rectangle (from the server), this puts into an XImage
    structure (in the client) the actual pixel values that were on the
    server.  XGetImage generates a protocol request to the server and
    expects some response back to the client.
    
    XGetPixel is a client-side routine that extracts the pixel value from
    the XImage structure resident in the client.
2045.6Server extension?HANNAH::MESSENGERBob MessengerWed Jan 17 1990 10:3026
Re: .5

If you XGetImage from a window, what happens if the window is partially
obscured?  It seems like you wouldn't be able to read any pixels that weren't
visible.  To be safe, maybe you need to force the window to the top of the
stacking order before trying to read from it.

XGetImage from a pixmap, on the other hand, would always work (barring some
other problem).

Re: .3, .4

I think if you really want to implement flood properly you should write a
server extension.  This would probably be hard to do but it should give you
the best possible performance.  You might be able to take advantage of whatever
hardware assist was available on each server, although in that case you'd need
a different implementation of the extension on each server.

On the other hand, you'd still have to implement this in your application on
the client side, because you couldn't be sure that the extension would exist
in every server.

Of course writing a server extension might be out of the question if you're
under time constraints.

				-- Bob
2045.7PSW::WINALSKICareful with that VAX, EugeneWed Jan 17 1990 15:035
The way my applications handle this is they remember what they wrote to the
screen (they have to, anyway, to handle expose events).  Thus, I don't have to
ask the window what's where.  I already know.

--PSW
2045.8On the way...WPOMM2::ZAMBOTTIWed Jan 17 1990 20:1621
Hi Ron,

Re .4 : Well I've written the routines and know I have to debug them.  Let
you know when they are ready.

These fill and flood routines emulate the routines from a graphics package
called halo.  You see thats my current project ; write a halo GKS emulator
for X windows.

Actually it will only be a subset of halo.  Unless I do some 3am stuff and
complete it anyway!

One of the features that is required though is stroke/vector text. Let you
know when I have this going as well.

Re. 6 : Yeah great if you want to make it propriety again but one of the
conditions of the port is that it is platform transportable.  Shucks!

Regards,

Walter.
2045.9Done already in DECpaintDAVIS::peterMon Jan 22 1990 16:004
DECpaint (dxpaint) already does flood fill in this way.  Contact
Johathan Joseph (SARAH::J_JOSEPH) or John Hainsworth
(SARAH::HAINSWORTH) for more information.  I think John found some ways
to get reasonable performance out of it.