The TVRD function returns the contents of the specified rectangular portion of the current graphics window or device. ( X 0 , Y 0 ) is the coordinate of the lower left corner of the area to be read and N x , N y is the size of the rectangle in columns and rows. The result is a byte array of dimensions N x by N y . All parameters are optional. If no arguments are supplied, the entire display device area is read.
On some systems, when backing store is provided by the window system (the RETAIN keyword to DEVICE or WINDOW is set to 1), reading data from a window using TVRD may cause unexpected results. For example, data may be improperly read from the window even when the image displayed on screen is correct. Having IDL provide the backing store (set the RETAIN keyword to 2) ensures that the window contents will be read properly. More detailed notes about TVRD and the X Window system can be found below in Unexpected Results Using TVRD with X Windows .
If this keyword is present, it indicates that a true-color image is to be read, if the display is capable. The value assigned to TRUE specifies the index of the dimension over which color is interleaved. The result is an (3, n x , n y ) pixel-interleaved array if TRUE is 1; or an ( n x , 3, n y ) line-interleaved array if TRUE is 2; or an ( n x , n y , 3) image-interleaved array if TRUE is 3.
IDL uses the Xlib function
to implement TVRD. The following quote is from the documentation for XGetSubImage() found in
The X Window System
by Robert W. Scheifler and James Gettys, Second Edition, page 174. It explains the reasons for the behaviors described above:
"If the drawable is a window, the window must be viewable, and it must be the case that if there were no... overlapping windows, the specified rectangle of the window would be fully visible on the screen, ... or a BadMatch error results. If the window has backing-store, then the backing-store contents are returned for regions of the window that are obscured... If the window does not have backing-store, the returned contents of such obscured regions are undefined."
Hence, the first behavior is caused by attempting to use TVRD on an obscured window that does not have backing store provided by the X server. The result in this case is undefined, meaning that the different servers can produce entirely different results. Many servers simply return the image of the obscuring window.
The second behavior is caused by attempting to read from a non-viewable (i.e., unmapped) window. Although IDL could refuse to allow TVRD to work with unmapped windows, some X servers return valid and useful results. Therefore, TVRD is allowed to attempt to read from unmapped windows.
For a full description of backing store, See Backing Store . Note that under X Windows, backing store is a request that may or may not be honored by the X server. Many servers will honor backing store for 8-bit visuals but ignore them for 24-bit visuals because they require three times as much memory.