File: BitsPlusClut2Texture.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 (22 lines) | stat: -rw-r--r-- 809 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function texturePtr = BitsPlusClut2Texture(windowPtr, clut)
% texturePtr = BitsPlusClut2Texture(windowPtr, clut)
%
%   Generates a PsychToolbox texture containing the CLUT + magic code
%   required to set the clut in Bits++ mode.
%
%   'clut' should be a 256x3 matrix consisting of values in the range
%   specified by Screen('ColorRange'), which is by default [0, 255].

if nargin ~= 2
    error('Usage: texturePtr = BitsPlusClut2Texture(windowPtr, clut)');
end

% Convert the clut into the current color range.
colorRange = Screen('ColorRange', windowPtr);
clut = clut / colorRange .* (2^16 - 1);

% Convert the clut into the special one for Bits++.
newClutRow = BitsPlusEncodeClutRow(clut);

% Generate the texture holding the Bits++ clut.
texturePtr = Screen('MakeTexture', windowPtr, uint8(newClutRow));