blob: e66c71a9c411cb57cfdd7c216bc0d04ed882112f (
plain) (
blame)
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
|
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962
static GLubyte *oimage = NULL;
static unsigned long
extract_pixel( unsigned long pp )
{
// int x,y;
unsigned long pout;
int r1;
short rr, gg, bb, aa;
{
float d;
// float Ner,Neg,Neb,Nir,Nig,Nib;
unsigned long q;
q = pp;
rr = ( short ) ( q & ( 0xff ) );
gg = ( short ) ( ( q & ( 0xff00 ) ) >> 8 );
bb = ( short ) ( ( q & ( 0xff0000 ) ) >> 16 );
aa = ( short ) ( ( q & ( 0xff000000 ) ) >> 24 );
d = 255 - sqrt( ( rr - gg ) * ( rr - gg ) );
aa = ( short ) d;
r1 = ( int ) ( 255.0f - rr );
if( gg > rr )
gg = rr;
rr = ( short ) ( aa * ( float ) rr / 255.0 );
gg = ( short ) ( aa * ( float ) gg / 255.0 );
bb = ( short ) ( aa * ( float ) bb / 255.0 );
}
pout = rr + ( gg << 8 ) + ( bb << 16 ) + ( aa << 24 );
return ( pout );
}
|