~ubuntu-branches/ubuntu/maverick/imagination/maverick

« back to all changes in this revision

Viewing changes to transitions/fade.c

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2009-07-07 09:09:38 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090707090938-jvaub13ijh53oawy
Tags: 1.5-1ubuntu1
* Merge with debian unstable (LP: #392874), Ubuntu remaining changes:
  - debian/control:
    + Move libav*-unstripped-* packages to Recommends as suggested by
      upstream.
    + Improve long description.
    + Add watch file.
  - debian/copyright: Replace deprecated symbol (C) with ©.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (c) 2009 Giuseppe Torelli <colossus73@gmail.com>
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 *
 
18
 */
 
19
 
 
20
#include "export_to_ppm.h"
 
21
#include <gdk/gdk.h>
 
22
 
 
23
/* Local functions declarations */
 
24
static void
 
25
transition_render( GdkDrawable *window,
 
26
                                   GdkPixbuf   *image_from,
 
27
                                   GdkPixbuf   *image_to,
 
28
                                   gdouble      progress,
 
29
                                   gint         file_desc,
 
30
                                   gint         direction );
 
31
 
 
32
/* Plug-in API */
 
33
void
 
34
img_get_plugin_info( gchar  **group,
 
35
                                         gchar ***trans )
 
36
{
 
37
        gint i = 0;
 
38
 
 
39
        *group = "Fade";
 
40
 
 
41
        *trans = g_new( gchar *, 4 );
 
42
        (*trans)[i++] = "Cross Fade";
 
43
        (*trans)[i++] = "img_cross_fade";
 
44
        (*trans)[i++] = GINT_TO_POINTER( 19 );
 
45
        (*trans)[i++] = NULL;
 
46
}
 
47
 
 
48
void img_cross_fade( GdkDrawable *window, GdkPixbuf *image_from, GdkPixbuf *image_to, gdouble progress, gint file_desc )
 
49
{
 
50
        transition_render( window, image_from, image_to, progress, file_desc, 1 );
 
51
}
 
52
 
 
53
/* Local functions definitions */
 
54
static void
 
55
transition_render( GdkDrawable *window,
 
56
                                   GdkPixbuf   *image_from,
 
57
                                   GdkPixbuf   *image_to,
 
58
                                   gdouble      progress,
 
59
                                   gint         file_desc,
 
60
                                   gint         direction )
 
61
{
 
62
        cairo_t         *cr;
 
63
        cairo_surface_t *surface;
 
64
        gint             width, height;
 
65
 
 
66
        gdk_drawable_get_size( window, &width, &height );
 
67
 
 
68
        if( file_desc < 0 )
 
69
        {
 
70
                cr = gdk_cairo_create( window );
 
71
        }
 
72
        else
 
73
        {
 
74
                surface = cairo_image_surface_create( CAIRO_FORMAT_RGB24,
 
75
                                                                                          width, height );
 
76
                cr = cairo_create( surface );
 
77
        }
 
78
 
 
79
        gdk_cairo_set_source_pixbuf( cr, image_from, 0, 0 );
 
80
        cairo_paint( cr );
 
81
 
 
82
        gdk_cairo_set_source_pixbuf( cr, image_to, 0, 0 );
 
83
        cairo_paint_with_alpha(cr, progress);
 
84
        cairo_destroy(cr);
 
85
 
 
86
        if(file_desc < 0)
 
87
                return;
 
88
 
 
89
        img_export_cairo_to_ppm(surface, file_desc);
 
90
        cairo_surface_destroy(surface);
 
91
}