/
MovieStripeHandler.php
51 lines (42 loc) · 1.27 KB
/
MovieStripeHandler.php
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
<?php
/* ===============================================================
* MythCut
* (c) 2011,2012 Mario Weilguni
* roadrunner6@gmx.at
* Licenced under GNU General Public Licence Version 3 or higher
* See misc/LICENSE for details
*===============================================================*/
class MovieStripeHandler extends MovieHandler {
private $W = 900;
private $H = 32;
protected function process(ViewBag $viewbag) {
$movie = $this->movie;
$list = $this->list;
$im = imagecreate($this->W, $this->H);
$background_color = imagecolorallocate($im, 0xc0, 0xc0, 0xc0);
imagefilledrectangle($im, 0, 0, $this->W-1, $this->H-1, $background_color);
$black = imagecolorallocate($im, 0,0,0);
imagerectangle($im, 0, 0, $this->W-1, $this->H-1, $black);
$red = imagecolorallocate($im, 0xc0, 0, 0);
$max = $movie->getMaxSeek();
$scale = DoubleVal($this->W) / DoubleVal($max);
foreach($list->getCutRegions() as $v) {
$left = $v[0];
$right = $v[1];
if($right == -1)
$right = $max;
$x1 = IntVal($left * $scale);
$x2 = min($this->W-1, IntVal($right * $scale));
imagefilledrectangle($im,
$x1,
1,
$x2,
$this->H - 2,
$red);
}
header("Content-Type: image/png");
header("Cache-Control: must-revalidate");
imagepng($im);
exit;
}
}