repeated use of TVRD() gives different results [message #93741] |
Tue, 11 October 2016 11:44  |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
This is the sort of IDL quirk that I think drove David Fanning into retirement.
The following two lines repeatedly TVRD() the value of a screen pixel
IDL> window,0,xsize = 640,ysize=512 ;Create a window
IDL> for i=0,19 do print,tvrd(635,507,1,1,/true) ;Read one pixel
On my El Capitan Macbook running IDL V8.5.1 in decomposed mode, I get
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
112 97 46
0 0 8
8 0 0
0 0 14
0 0 0
0 0 0
0 0 0
0 0 0
113 120 46
46 120 113
114 112 47
0 0 14
0 0 14
In other words, repeatedly reading the same pixel does not give the same results. (This does *not* happen on my Linux box but only on the Mac.) Coyote graphics reads a corner pixel to decide whether you are using a "traditional" IDL plot (black background), or modern graphics (white background). But after the first call, this test can randomly fail because the result of TVRD() is unpredictable.
(I am mostly weened off of direct graphics, but still need to maintain legacy code.) --Wayne
Current graphics device: X
Server: X11.0, The X.Org Foundation, Release 11704000
Display Depth, Size: 24 bits, (1440,878)
Visual Class: TrueColor (4)
Bits Per RGB: 8 (8/8/8)
Physical Color Map Entries (Emulated / Actual): 256 / 256
Colormap: Shared, 16777216 colors. Translation table: Bypassed
Graphics pixels: Decomposed, Dither Method: Ordered
Write Mask: 16777215 (decimal) ffffff (hex)
Graphics Function: 3 (copy)
Current Font: <default>, Current TrueType Font: <default>
Default Backing Store: Req from Server.
Window Status: ---------------------
id typ( x, y, backing store) id typ( x, y, backing store)
0: Win( 640, 512, Req from Server)
IDL> !VERSION
{
"ARCH": "x86_64",
"OS": "darwin",
"OS_FAMILY": "unix",
"OS_NAME": "Mac OS X",
"RELEASE": "8.5.1",
"BUILD_DATE": "Nov 14 2015",
"MEMORY_BITS": 64,
"FILE_OFFSET_BITS": 64
|
|
|
Re: repeated use of TVRD() gives different results [message #93742 is a reply to message #93741] |
Tue, 11 October 2016 12:55   |
Burch
Messages: 28 Registered: December 2013
|
Junior Member |
|
|
Hmmm, it seems to depend on the type of backing store. On my El Capitan Mac Pro it works fine when set to Pixmap but fails for the others. It will take someone more knowledgeable than me to explain why. Just out of curiosity, is the default backing store different between your Linux and Mac? Or does it work correctly regardless of the backing store setting on the Linux computer?
'IDL_GR_X_RETAIN' set to 0 (None):
IDL> window,0,xsize = 640,ysize=512
IDL> for i=0,19 do print,tvrd(635,507,1,1,/true)
0 0 0
0 0 32
110 117 97
110 117 97
110 117 97
0 0 2
0 0 0
0 0 32
0 0 0
0 0 0
0 0 0
120 113 81
0 0 0
0 48 58
0 0 0
0 0 32
0 0 0
0 0 0
0 0 32
0 0 0
IDL> help, /device
Available Graphics Devices: CGM HP LJ NULL PCL PRINTER PS REGIS TEK X Z
Current graphics device: X
Server: X11.0, The X.Org Foundation, Release 11604000
Display Depth, Size: 24 bits, (1920,1080)
Visual Class: TrueColor (4)
Bits Per RGB: 8 (8/8/8)
Physical Color Map Entries (Emulated / Actual): 256 / 256
Colormap: Shared, 16777216 colors. Translation table: Bypassed
Graphics pixels: Decomposed, Dither Method: Ordered
Write Mask: 16777215 (decimal) ffffff (hex)
Graphics Function: 3 (copy)
Current Font: <default>, Current TrueType Font: <default>
Default Backing Store: None.
Window Status: ---------------------
id typ( x, y, backing store) id typ( x, y, backing store)
0: Win( 640, 512, None)
'IDL_GR_X_RETAIN' set to 1 (Server, System):
IDL> window,0,xsize = 640,ysize=512
IDL> for i=0,19 do print,tvrd(635,507,1,1,/true)
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
110 117 97
0 0 0
0 0 0
0 0 32
0 0 0
110 117 97
0 0 0
0 0 0
0 0 32
0 0 32
0 0 32
IDL> help, /device
Available Graphics Devices: CGM HP LJ NULL PCL PRINTER PS REGIS TEK X Z
Current graphics device: X
Server: X11.0, The X.Org Foundation, Release 11604000
Display Depth, Size: 24 bits, (1920,1080)
Visual Class: TrueColor (4)
Bits Per RGB: 8 (8/8/8)
Physical Color Map Entries (Emulated / Actual): 256 / 256
Colormap: Shared, 16777216 colors. Translation table: Bypassed
Graphics pixels: Decomposed, Dither Method: Ordered
Write Mask: 16777215 (decimal) ffffff (hex)
Graphics Function: 3 (copy)
Current Font: <default>, Current TrueType Font: <default>
Default Backing Store: Req from Server.
Window Status: ---------------------
id typ( x, y, backing store) id typ( x, y, backing store)
0: Win( 640, 512, Req from Server)
'IDL_GR_X_RETAIN' set to 2 (Pixmap):
IDL> window,0,xsize = 640,ysize=512
IDL> for i=0,19 do print,tvrd(635,507,1,1,/true)
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
IDL> help, /device
Available Graphics Devices: CGM HP LJ NULL PCL PRINTER PS REGIS TEK X Z
Current graphics device: X
Server: X11.0, The X.Org Foundation, Release 11604000
Display Depth, Size: 24 bits, (1920,1080)
Visual Class: TrueColor (4)
Bits Per RGB: 8 (8/8/8)
Physical Color Map Entries (Emulated / Actual): 256 / 256
Colormap: Shared, 16777216 colors. Translation table: Bypassed
Graphics pixels: Decomposed, Dither Method: Ordered
Write Mask: 16777215 (decimal) ffffff (hex)
Graphics Function: 3 (copy)
Current Font: <default>, Current TrueType Font: <default>
Default Backing Store: Pixmap.
Window Status: ---------------------
id typ( x, y, backing store) id typ( x, y, backing store)
0: Win( 640, 512, Pixmap)
IDL> !version
{
"ARCH": "x86_64",
"OS": "darwin",
"OS_FAMILY": "unix",
"OS_NAME": "Mac OS X",
"RELEASE": "8.5",
"BUILD_DATE": "Jul 7 2015",
"MEMORY_BITS": 64,
"FILE_OFFSET_BITS": 64
}
-Jeff
|
|
|
|
|
|
|
Re: repeated use of TVRD() gives different results [message #93825 is a reply to message #93750] |
Fri, 28 October 2016 12:03  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Wednesday, October 12, 2016 at 6:42:06 AM UTC-7, ri...@crd.ge.com wrote:
> There's a note in the documentation under TVRD about "unexpected results" unless IDL is providing the backing store (which I hadn't seen before). Ages ago, I found that TVRD() didn't work properly when the graphics window extended off the edge of the screen. (I solved it by copying the window's contents to a pixmap and calling TVRD on the pixmap.) The note explains why.
>
A long time ago, I used to have problems with tvrd() when the backing store was set to 1, for some versions of the X server under Linux. It would copy whatever was shown in that area of the screen, meaning if there was another window over the window I was reading from, that window's contents would show up in the result of tvrd(). I have not seen the problem in many years, but I rarely use direct graphics, and I generally stopped using tvrd() from a real window (as opposed to a pixmap), except when doing it interactively (so I would then see the result right away and notice any problems).
|
|
|