/usr/share/psychtoolbox-3/PsychAlphaBlending/SetSourceAlpha.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 | function [newSourceImage, newDestinationImage]=SetSourceAlpha(sourceFactorStr, alpha, sourceImage, destinationImage)
% [newSourceMat, newDestinationMat]=SetSourceAlpha(SourceFactorStr, alpha, sourceImage, destinationImage)
%
% Given an alpha blending factor, "sourceFactorStr", insert "alpha"
% into the source or destination image such that on alpha blending with the
% specified sourceFactorStr "alpha" is selected as the destination
% alpha.
%
% For some combinations of destination factor string and source factor
% string, SetSourceAlpha may undo a subsequent call to SetDestinationAlpha
% or be undone by a previous call to SetDestinationAlpha. This happens
% when both the destination factor string and the source factor string
% specify the same location of alpha values yet store different alpha
% values. For example, if both the source alpha and destination alpha are
% drawn from the source alpha plane (GL_SRC_ALPHA) then setting the source
% alpha to 0 would also change the destination alpha to 0. Both source and
% destination surfaces would share the source surface alpha plane for
% storage of the alpha value.
%
% SetAlphaDestination helps test OpenGL alpha blending precision.
%
% see also: PsychAlphaBlending
% HISTORY
%
% mm/dd/yy
%
% 2/17/05 awi wrote it.
%expand alpha to be an alpha plane
destinationMatDims=size(destinationImage);
alphaMatDims=size(alpha) ;
if alphaMatDims(1)*alphaMatDims(2)==1
alphaPlane=repmat(alpha, destinationMatDims(1), destinationMatDims(2));
else
alphaPlane=alpha;
end
glOnePlane=repmat(255, destinationMatDims(1), destinationMatDims(2));
glZeroPlane=zeros(destinationMatDims(1), destinationMatDims(2));
%insert the alpha into the storage location for alpha
if strcmp(sourceFactorStr, 'GL_ZERO')
if any(any(alpha ~= 0))
error('destination factor GL_ZERO is incompatible with alpha values not equal to 0.');
end
%change nothing
newSourceImage=sourceImage;
newDestinationImage=destinationImage;
elseif strcmp(sourceFactorStr, 'GL_ONE')
if any(any(alpha ~= 255))
error('destination factor GL_ONE is incompatible with alpha values not equal to 255.');
end
%change nothing
newSourceImage=sourceImage;
newDestinationImage=destinationImage;
elseif strcmp(sourceFactorStr, 'GL_DST_COLOR')
newSourceImage=sourceImage;
newDestinationImage=repmat(alphaPlane,[1,1,4]);
elseif strcmp(sourceFactorStr, 'GL_ONE_MINUS_DST_COLOR')
newSourceImage=sourceImage;
newDestinationImage=255-repmat(alphaPlane,[1,1,4]);
elseif strcmp(sourceFactorStr, 'GL_SRC_ALPHA');
%change source image
newSourceImage=sourceImage;
newSourceImage(:,:,4)=alphaPlane;
newDestinationImage=destinationImage;
elseif strcmp(sourceFactorStr, 'GL_ONE_MINUS_SRC_ALPHA')
%change source image
newSourceImage=sourceImage;
newSourceImage(:,:,4)=255-alphaPlane;
newDestinationImage=destinationImage;
elseif strcmp(sourceFactorStr, 'GL_DST_ALPHA');
%change the destination image
newSourceImage=sourceImage;
newDestinationImage=destinationImage;
newDestinationImage(:,:,4)=alphaPlane;
elseif strcmp(sourceFactorStr, 'GL_ONE_MINUS_DST_ALPHA');
%change the destination image
newSourceImage=sourceImage;
newDestinationImage=destinationImage;
newDestinationImage(:,:,4)=255-alphaPlane;
elseif strcmp(sourceFactorStr, 'GL_SRC_ALPHA_SATURATE');
%change the source image
%change the destination image
newSourceImage=sourceImage;
newDestinationImage=destinationImage;
newSourceImage(:,:,4)=alphaPlane;
newDestinationImage(:,:,4)=255-alphaPlane;
else
error('Argument "sourceFactorStr" is unrecognized or invalid');
end
|