comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » repeated use of TVRD() gives different results
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
repeated use of TVRD() gives different results [message #93741] Tue, 11 October 2016 11:44 Go to next message
wlandsman is currently offline  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 Go to previous messageGo to next message
Burch is currently offline  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 #93748 is a reply to message #93742] Tue, 11 October 2016 20:29 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
Nice catch! Yes, TVRD() works consistently on both my Mac and my Linux box when I have set pixmap backing store (either IDL_GR_X_RETAIN = 2 or device,retain = 2). And TVRD() does not work consistently when RETAIN = 0 or RETAIN = 1. Thanks, --Wayne


On Tuesday, October 11, 2016 at 3:55:52 PM UTC-4, Jeff B wrote:
> 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?
Re: repeated use of TVRD() gives different results [message #93750 is a reply to message #93748] Wed, 12 October 2016 06:41 Go to previous messageGo to next message
Bill Nel is currently offline  Bill Nel
Messages: 31
Registered: October 2010
Member
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.

--Wayne
Re: repeated use of TVRD() gives different results [message #93756 is a reply to message #93750] Wed, 12 October 2016 20:11 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
Thanks. Interestingly, I don't find any other problems with using IDL_GR_X_RETAIN = 1 (the default value) on my MacBook. The backing store seems to work fine, and you only run into trouble when using TVRD().

It turns out that this has been a cause of a lot of mysterious color problems I've had when using Coyote graphics. The safe fix is to always set RETAIN=2 but I've also sent a pull request to https://github.com/idl-coyote/coyote to update CGCOLOR so that it never uses TVRD() on X windows when IDL_GR_X_RETAIN is less than 2. I've also put an updated CGCOLOR on
http://idlastro.gsfc.nasa.gov/ftp/pro/coyote/cgcolor.pro

--Wayne



On Wednesday, October 12, 2016 at 9:42:06 AM UTC-4, 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.
>
> --Wayne
Re: repeated use of TVRD() gives different results [message #93786 is a reply to message #93741] Sat, 15 October 2016 11:36 Go to previous messageGo to next message
rawahranger is currently offline  rawahranger
Messages: 14
Registered: March 2016
Junior Member
Wayne Landsman writes:

> This is the sort of IDL quirk that I think drove David Fanning into retirement.

Indeed! :-)

I see Matt Savoie took care of this in the repository while I was off hiking, so I think you are good. Thanks, Matt!

David
Re: repeated use of TVRD() gives different results [message #93825 is a reply to message #93750] Fri, 28 October 2016 12:03 Go to previous message
penteado is currently offline  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).
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Technique to find maximum in 100x100 element moving box
Next Topic: array of structures -- error Conflicting data structures

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 09:20:10 PDT 2025

Total time taken to generate the page: 0.00424 seconds