~ubuntu-branches/ubuntu/trusty/imagination/trusty-updates

« back to all changes in this revision

Viewing changes to transitions/roller_blind.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 <gdk/gdk.h>
21
 
 
22
 
void img_transition_set_name(gchar **name)
23
 
{
24
 
        *name = "Roller Blind";
25
 
}
26
 
 
27
 
void img_transition_render(GdkDrawable *window, GdkPixbuf *image_from, GdkPixbuf *image_to, gdouble progress, gint file_desc)
28
 
{
29
 
        cairo_t *cr;
30
 
        cairo_surface_t *surface;
31
 
        gint     width, height, i, j;
32
 
        static gint count = 0;
33
 
 
34
 
        gdk_drawable_get_size(window, &width, &height);
35
 
 
36
 
        if(file_desc < 0)
37
 
        {
38
 
                cr = gdk_cairo_create(window);
39
 
        }
40
 
        else
41
 
        {
42
 
                surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width, height);
43
 
                cr = cairo_create(surface);
44
 
        }
45
 
 
46
 
        gdk_cairo_set_source_pixbuf(cr,image_from,0,0);
47
 
        cairo_paint(cr);
48
 
 
49
 
        gdk_cairo_set_source_pixbuf(cr,image_to,0,0);
50
 
 
51
 
        for (i = 0; i <= height; i+= 10)
52
 
        {
53
 
                for (j=0 ; j < count * progress; j++)
54
 
                {
55
 
                        cairo_move_to(cr, 0, i+j);
56
 
                        cairo_line_to(cr, width, i+j);
57
 
                }
58
 
        }
59
 
        count++;
60
 
        if (progress > 1)
61
 
                count = 0;
62
 
 
63
 
        cairo_stroke(cr);
64
 
        cairo_destroy(cr);
65
 
 
66
 
        if(file_desc < 0)
67
 
                return;
68
 
 
69
 
        img_export_cairo_to_ppm(surface, file_desc);
70
 
        cairo_surface_destroy(surface);
71
 
}