Pro Rdpix2, Image,X0, Y0 ;Read the value of the pixel under the cursor ;Display x,y and the pixel value under the cursor ;reviced from rdpix.pro '91.1.20 k.i. ;+ ; NAME: ; RDPIX2 ; PURPOSE: ; Display the X, Y, and pixel value of the cursor ; CATEGORY: ; Image display ; CALLING SEQUENCE: ; RDPIX, Image [, X0, Y0] ; INPUTS: ; Image = Array containing values that are displayed. May be ; any type. Rather than pixel values being read from the display ; they are taken from this parameter, avoiding scaling difficulties. ; OPTIONAL INPUT PARAMETERS: ; X0, Y0 = Optional location of lower left corner of image area on ; screen. ; OUTPUTS: ; None. ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; The X, Y and value of pixel under the cursor are constantly ; displayed. ; ; Pressing left or center mouse button, makes a new line of output, ; saving the old. ; Pressing right mouse button, exits the procedure. ; ; RESTRICTIONS: ; None. ; PROCEDURE: ; Straightforward. ; MODIFICATION HISTORY: ; DMS, Dec, 1987. ;- on_error,2 ;Return to caller if an error occurs print,'Press left or center mouse button for new output line." print,'... right mouse button to exit.' s = size(image) if s(0) ne 2 then message, 'Image parameter not 2d.' s(1) = s(1)-1 ;To n-1 s(2) = s(2)-1 !err=0 x1=-1 & y1=-1 ;Previous values if n_elements(x0) le 0 then x0 = 0 if n_elements(y0) le 0 then y0 = 0 if s(s(0)+1) ge 4 then form = 'F' else form = 'I' cr = string("15b) form="($,'x=',i4,', y=',i4,', value=',"+form+",a)" device,cursor_standard=132 ; cursor to arrow while !err ne 4 do begin tvrdc,x,y,3,/dev if (!err and 3) ne 0 then begin ;New line? print,form="($,a)",string("12b) while (!err ne 0) do begin wait,.1 & tvrdc,x,y,0,/dev & end endif xyouts,x,y,'!I!9n',size=2,alignment=0.5,color=255,/dev x = x-x0 & y = y - y0 if !order ne 0 then yy = (s(2) > !d.y_vsize) - 1 - y $ else yy = y if (x le s(1)) and (yy le s(2)) and (x ge 0) and $ (y ge 0) then $ print,form = form, x,y,Image(x,yy),cr x1 = x & y1=y endwhile device,cursor_standard=34 ; cursor to crosshair print,form="(/)" end