psychopy/psychopy — pull request #639 by jaybo (2014-07-30 19:34:49+00:00)
Title: BF: 504 SetDeviceGammaRamp fails on Win x64

On Win x64 SetDeviceGammaRamp() fails about half the time due to an improper sign extension bug in pyglet. This fix should work 32/64 and will also continue to work once pyglet fixes the bug.

The problem is due to a sign extension bug in the Win32 wrapper for GetDC in piglet. On x64 if the high order bit of (LOWORD) hDC is set (about half the time), then it is incorrectly sign extended, creating a negative value. Subsequently, trying to use this bad value gives failures on Set/GetDeviceGammaRamp.

hDC values are always less than 32 bits, see:
http://blogs.msdn.com/b/oldnewthing/archive/2012/09/13/10348876.aspx
http://blogs.technet.com/b/markrussinovich/archive/2010/03/31/3322423.aspx