File: BitsPlusSetColor.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (41 lines) | stat: -rw-r--r-- 1,313 bytes parent folder | download | duplicates (7)
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
function BitsPlusSetColor(windowPtr,entry,rgb)
% SetColorBitspp(windowPtr,entry,rgb)
% 
% Set the specified entry of the clut, using the Bits++ box and our
% frame buffer conventions.
% 
% Prior to using this routine, Bits++ box must be in
% framebuffer load mode.
%
% This routine is not required to be speedy, and it isn't.
%
% xx/xx/02  jmh  Wrote it, but didn't comment.
% 2/23/03   dhb  Added comments.
% 2/28/03   dhb, ptw  Add delay to make sure glitch has settled.
%                Changed name, fixed up.
% 3/8/03    dhb  Remove call to bitsplus.

% Get bits rectangle.
bitsPlusRect = [0 0 524 1];

% Open offscreen memory to store old clut
offWindow = SCREEN(windowPtr,'OpenOffscreenWindow',0,bitsPlusRect);

% Extract the current clut and decode
currentClutRow = double(Screen(windowPtr,'GetImage',bitsPlusRect));
currentClut = BitsPlusDecodeClutRow(currentClutRow);

% Set the appropriate entry
newClut = currentClut; newClut(entry+1,:) = rgb';

% Write it into offscreen memory
newClutRow = BitsPlusEncodeClutRow(newClut);
Screen(offWindow,'PutImage',newClutRow,bitsPlusRect);

% Copy it fast and in sync with video blanking
Screen(windowPtr,'WaitBlanking');
WaitSecs(0.003);
Screen('CopyWindow',offWindow,windowPtr,bitsPlusRect,bitsPlusRect);

% Close up offscreen memory
Screen(offWindow,'Close');