/usr/share/psychtoolbox-3/PsychOneliners/WhiteIndex.m is in psychtoolbox-3-common 3.0.11.20131230.dfsg1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | function white=WhiteIndex(windowPtrOrScreenNumber)
% color=WhiteIndex(windowPtrOrScreenNumber)
% Returns the intensity value to produce white at the current screen depth,
% assuming a standard color lookup table for that depth. E.g.
%
% white=WhiteIndex(w);
% Screen(w,'FillRect',white);
%
% See BlackIndex.
%
% 3/10/98 dgp Wrote it.
% 3/30/98 dgp Consider only one channel, even for 16 and 32 bit modes.
% 3/8/2000 emw Added Platform Conditionals
% 3/8/2000 dgp Fixed platform conditionals
% 3/30/2004 awi Added OS X case. For now OS X only supports true-color mode, so
% WhiteIndex behavior on OS X will have to change when we add
% more depth modes.
% 1/29/05 dgp Cosmetic.
% 03/1/08 mk Adapted to the much more flexible scheme of PTB-3.
% 08/24/13 mk Select 1.0 as default white index if PsychDefaultSetup(2+) was used.
% Default colormode to use: 0 = clamped, 0-255 range. 1 = unclamped 0-1 range.
global psych_default_colormode;
if nargin~=1
error('Usage: color=WhiteIndex(windowPtrOrScreenNumber)');
end
% Is a default colormode specified via psych_default_colormode variable and the level
% is at least 1? If so, future created onscreen windows will have a [0;1] colorrange
% without clamping by default.
if ~isempty(psych_default_colormode) && (psych_default_colormode >= 1)
% 0-1 normalized range preset. A default white index of 1.0 is a reasonable assumption,
% as PsychImaging('Openwindow') would select 1.0 as maximum value:
defaultwhite = 1;
else
% No preset: Assume a traditional default of 255:
defaultwhite = 255;
end
% Screen number given?
if ~isempty(find(Screen('Screens')==windowPtrOrScreenNumber))
% Need to find corresponding onscreen window:
windows = Screen('Windows');
if isempty(windows)
% No open windows associated with this screen. Just return the
% default value of "defaultwhite", our default maximum pixel color component
% value, which is valid irrespective of the actual pixel depths of
% the screen as OpenGL takes care of such things / is invariant to
% them:
white = defaultwhite;
return;
end
% At least one onscreen window open: Find the one with this screen as
% parent:
win = [];
for i=windows
if (Screen('WindowKind', i) == 1)
% It's an onscreen window. Associated with this screen?
if windowPtrOrScreenNumber == Screen('WindowScreenNumber', i)
% This is it:
win = i;
break;
end
end
end
if isempty(win)
% No onscreen window on this screen. Return default "defaultwhite":
white = defaultwhite;
return;
end
% Onscreen window id assigned to 'win'. Leave the rest of the job to
% common code below...
else
% No screen number given. Window number given?
if isempty(find(Screen('Windows')==windowPtrOrScreenNumber))
% No window number either. This is an invalid index:
error('Provided "windowPtrOrScreenNumber" is neither a valid screen, nor window!');
end
% Its a window: Assign it to 'win'
win = windowPtrOrScreenNumber;
end
% If we reach this point then we have the window handle of the relevant
% window to query in 'win'. use Screen('ColorRange') to query its maximum
% color value. By default this will be again "255" - the maximum for a 8bpc
% standard framebuffer. However, when used with special HDR
% devices/framebuffers or some specific setup was done via
% Screen('ColorRange'), the maximum value corresponding to
% white may be any positive number:
white = Screen('ColorRange', win);
% Done.
return;
|