vi_gamma.pl
959 Bytes
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
sub vi_gamma
{
$gamma_enable = $_[0];
$gamma_dither_enable = $_[1];
$rgb = $_[2];
$rand = $_[3];
$sync = $_[4];
$_[5] = sprintf("0x%.2x", $ogamma_rgb);
$_[6] = $ogamma_sync;
$blank = $sync ? ((oct($rgb) & (1 << 7)) >> 7) : $oblank_reg;
$nblank_reg = $blank;
if ($gamma_dither_enable)
{
$sqrt_rgb = int(sqrt((oct($rgb) << 6) | oct($rand)));
}
else
{
$sqrt_rgb = int(sqrt(oct($rgb) << 6));
}
if ($rgb ne "0xff")
{
$dither_rgb = oct($rgb) + ($gamma_dither_enable & (oct($rand) >> 5));
}
else
{
$dither_rgb = 255;
}
$ngamma_rgb =
$sync ? ((oct($rgb) & (15 << 1)) >> 1) :
((! $blank) && ($gamma_enable ?
sqrt_rgb:
(($dither_rgb & (127 << 1)) >> 1)));
$ngamma_sync = $sync;
$ogamma_rgb = $ngamma_rgb;
$ogamma_sync = $ngamma_sync;
$oblank_reg = $nblank_reg;
}
1;
#EOF