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
|
#!/usr/bin/perl
use GD;
use strict;
use warnings;
#my $ref = new GD::Image->newTrueColor(100,100);
#my $white = $ref->colorAllocate(255,255,255);
#my $black = $ref->colorAllocate(0,0,0);
#my $blankMap = new GD::Image(720,540);
#my $white = $blankMap->colorAllocate(255,255,255);
#my $black = $blankMap->colorAllocate(0,0,0);
my @positions = ();
my @elements = ();
my $gdfont = "/usr/share/fonts/truetype/ttf-liberation/LiberationSans-Regular.ttf";
my $fontsize = 20;
my $linespace = 1.3;
my $left = 0;
my @bounds;
$bounds[1] = 150;
my $bgfile = "./lib/graphic/tv-bg-pal-size.png";
if ( $ARGV[0] ) {
$bgfile = $ARGV[0];
}
my $im = newFromPng GD::Image($bgfile,1);
#my $im = newFromJpeg GD::Image($bgfile);
my $white = $im->colorAllocate(255,255,255);
#my $black = $im->colorAllocate( 0, 0, 0);
#$im->interlaced(undef);
#$im->transparent(-1);
#$im->colorDeallocate($white);
#$white = $im->colorAllocate(255,255,255);
#$im->rectangle(0,0,99,99,$black);
#$im->rectangle(0,0,59,99,$black);
my $line = "Dette er en test på øæåØÆÅ";
@bounds = $im->stringFT($white,$gdfont,$fontsize,0,220,130,$line);
#$im->string(gdMediumBoldFont,200,300,$line,$white);
writefile('foo.png');
#read_elements("elements.txt");
print join("-",@elements)."\n";
print join("-",@positions)."\n";
sub read_elements {
my $file = shift ;
my $position = 100;
my $line_distance = 30;
open F, "$file" or die "Cannot open $file for read :$!";
while (<F>) {
chomp;
push(@elements,$_);
push(@positions,$position);
$position += $line_distance;
}
close F;
}
sub writefile {
my $f = shift;
open(F,">",$f);
binmode F;
print F $im->png;
close F;
}
|