2
* Copyright (c) 2009 Giuseppe Torelli <colossus73@gmail.com>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License,or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU Library General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not,write to the Free Software
16
* Foundation,Inc.,59 Temple Place - Suite 330,Boston,MA 02111-1307,USA.
20
/* This header provides us with image manipulation libraries such
21
* as gdk-pixbuf and cairo. */
24
/* This function is part of the mandatory API that each plug-in
27
* name parameter of this function is a return location for
28
* plug-in name. You must fill it with unique name, which will
29
* be used to identify transition in transition type combo box. */
30
void img_transition_set_name(gchar **name)
35
/* This function is part of the mandatory API that each plug-in
38
* This is the function that does all the transition rendering.
40
* window GdkDrawable on which the final product should be drawn
41
* image_from Starting pixbuf.
42
* image_to End pixbuf. Both images are already scaled and transformed
43
* to fit into GdkDrawable.
44
* progress Value in range [0,1] which tells us how far the transition
45
* is (0 means we only started transition, 1 means the
46
* transition is finished).
47
* file_desc File descriptor for outputting finished image (this file
48
* descriptor represents the ffmpeg's stdin, on which we
49
* write produced image data). If the file descriptor is < 0,
50
* we should draw our produt on GtkDrawable.
52
* Note: Parts enclosed in SUGGESTED comments should not be changed, since
53
* most of the transitions will need them.
55
void img_transition_render(GdkDrawable *window, GdkPixbuf *image_from, GdkPixbuf *image_to, gdouble progress, gint file_desc)
59
cairo_surface_t *surface;
62
/* With this call we obtain the dimensions of our drawing area.
63
* We don't use these values in this plug-in, but this is really
65
gdk_drawable_get_size(window, &width, &height);
67
/* This is where we check if we need to output our product on the screen
68
* or write it to the file desc. */
71
cr = gdk_cairo_create(window);
75
surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height);
76
cr = cairo_create(surface);
80
/* Here we do our own drawing. In this example, we are fading image_to
81
* pixbuf over the image_from pixbuf. The amount of transparency is
82
* determined by the progress value (at the start of the transition,
83
* image_to is fully transparent and at the end fully opaque). */
84
gdk_cairo_set_source_pixbuf(cr,image_from,0,0);
87
gdk_cairo_set_source_pixbuf(cr,image_to,0,0);
88
cairo_paint_with_alpha(cr,progress);
95
/* This function takes the burden of converting drawing product
96
* to appropriate pixel data from plug-in write's shoulders. */
97
img_export_cairo_to_ppm(surface, file_desc);
98
cairo_surface_destroy(surface);