]> git.sesse.net Git - vlc/blob - doc/subtitles/vlc-gimp.pl
Fix detection of dvb headerfiles and fix GTK2_MAIN selection for PDA interface.
[vlc] / doc / subtitles / vlc-gimp.pl
1 #!/usr/bin/perl
2
3 use Gimp ":auto";
4 use Gimp::Fu;
5
6 sub vlc_subtitler_font
7 {
8
9     $shadowcolour=[0,0,0];
10     $textcolour=[255,255,255];
11     $backcolour=[0,0,255];
12     $font="-*-utopia-bold-r-*-*-21-*-*-*-*-*-*-*";
13     $border=3;
14     $alias=1;
15
16     $text="_  ";
17     for($i=33; $i<127; $i++)
18       { $text.=chr($i); $text.="  "; }
19
20     # Create a new image of an arbitrary size with 
21     $img = gimp_image_new(100, 100, RGB);
22     
23     # Create a new layer for the background of arbitrary size, and
24     # add it to the image
25     my $background = gimp_layer_new($img, 100, 100,
26                                     RGB, "Background", 100,
27                                     NORMAL_MODE);
28     gimp_image_add_layer($background, 1);
29
30     # Choose color of text
31     gimp_palette_set_foreground($textcolour);
32
33     # Create the text layer. Using -1 as the drawable creates a new layer.
34     my $text_layer = gimp_text_fontname($img, -1, 0, 0, $text,
35                                         $border, $alias,
36                                         xlfd_size($font), $font);
37
38     # Get size of the text drawable and resize the image and the
39     # background layer to this size.
40     my($width, $height) = ($text_layer->width, $text_layer->height);
41     gimp_image_resize($img, $width, $height, 0, 0);
42     gimp_layer_resize($background, $width, $height, 0, 0);
43
44     gimp_layer_delete($text_layer);
45
46     # Fill the background layer now when it has the right size.
47     gimp_palette_set_background($backcolour);
48     gimp_edit_fill($background, BG_IMAGE_FILL);
49
50     my $shadowlayer, $textlayer;
51
52     # Plot eight shadow copies of the text
53     gimp_palette_set_foreground($shadowcolour);
54     $shadowlayer = gimp_text_fontname($img, -1, 0, 0, $text,
55                                         $border, $alias,
56                                         xlfd_size($font), $font);
57     gimp_layer_translate($shadowlayer, -2, 0);
58     gimp_image_flatten($img);
59
60     gimp_palette_set_foreground($shadowcolour);
61     $shadowlayer = gimp_text_fontname($img, -1, 0, 0, $text,
62                                         $border, $alias,
63                                         xlfd_size($font), $font);
64     gimp_layer_translate($shadowlayer, 2, 0);
65     gimp_image_flatten($img);
66
67     gimp_palette_set_foreground($shadowcolour);
68     $shadowlayer = gimp_text_fontname($img, -1, 0, 0, $text,
69                                         $border, $alias,
70                                         xlfd_size($font), $font);
71     gimp_layer_translate($shadowlayer, 0, -2);
72     gimp_image_flatten($img);
73
74     gimp_palette_set_foreground($shadowcolour);
75     $shadowlayer = gimp_text_fontname($img, -1, 0, 0, $text,
76                                         $border, $alias,
77                                         xlfd_size($font), $font);
78     gimp_layer_translate($shadowlayer, 0, 2);
79     gimp_image_flatten($img);
80
81     gimp_palette_set_foreground($shadowcolour);
82     $shadowlayer = gimp_text_fontname($img, -1, 0, 0, $text,
83                                         $border, $alias,
84                                         xlfd_size($font), $font);
85     gimp_layer_translate($shadowlayer, -1, -1);
86     gimp_image_flatten($img);
87
88     gimp_palette_set_foreground($shadowcolour);
89     $shadowlayer = gimp_text_fontname($img, -1, 0, 0, $text,
90                                         $border, $alias,
91                                         xlfd_size($font), $font);
92     gimp_layer_translate($shadowlayer, -1, 1);
93     gimp_image_flatten($img);
94
95     gimp_palette_set_foreground($shadowcolour);
96     $shadowlayer = gimp_text_fontname($img, -1, 0, 0, $text,
97                                         $border, $alias,
98                                         xlfd_size($font), $font);
99     gimp_layer_translate($shadowlayer, 1, -1);
100     gimp_image_flatten($img);
101
102     gimp_palette_set_foreground($shadowcolour);
103     $shadowlayer = gimp_text_fontname($img, -1, 0, 0, $text,
104                                         $border, $alias,
105                                         xlfd_size($font), $font);
106     gimp_layer_translate($shadowlayer, 1, 1);
107     gimp_image_flatten($img);
108
109     # Plot the text itself
110     gimp_palette_set_foreground($textcolour);
111     $textlayer = gimp_text_fontname($img, -1, 0, 0, $text,
112                                         $border, $alias,
113                                         xlfd_size($font), $font);
114     gimp_image_flatten($img);
115
116     return $img;
117 }
118
119 # register the script
120 register "vlc_subtitler_font",
121     "vlc subtitler font",
122     "vlc subtitler font",
123     "Andrew Flintham",
124     "Andrew Flintham",
125     "2002-06-18",
126     "<Toolbox>/Xtns/Perl-Fu/VLC Subtitles Font",
127     "*",
128     [],
129     \&vlc_subtitler_font;
130
131 # Handle over control to gimp
132 exit main();