]> Pileus Git - ~andy/gtk/blob - docs/reference/gdk-pixbuf/tmpl/scaling.sgml
much longer long description added.
[~andy/gtk] / docs / reference / gdk-pixbuf / tmpl / scaling.sgml
1 <!-- ##### SECTION Title ##### -->
2 Scaling
3
4 <!-- ##### SECTION Short_Description ##### -->
5 Scaling pixbufs and scaling and compositing pixbufs
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 gdk-pixbuf contains functions to scale pixbufs, to scale pixbufs and
10 composite against an existing image, and to scale pixbufs and
11 composite against a solid color or checkerboard.  (Compositing a
12 checkerboard is a common way to show an image with an alpha-channel in
13 image-viewing and editing software.)
14 </para>
15 <para>
16 Since the full-featured functions (gdk_pixbuf_scale(),
17 gdk_pixbuf_composite(), and gdk_pixbuf_composite_color()) are
18 rather complex to use and have many arguments, two simple
19 convenience functions are provided, gdk_pixbuf_scale_simple()
20 and gdk_pixbuf_composite_color_simple() which create a
21 new pixbuf of a given size, scale an original image to fit,
22 and then return the new pixmap.
23 </para>
24
25 <para>
26 The following example demonstrates handling an expose event by
27 rendering the appropriate area of a source image (which is scaled to
28 fit the widget) onto the widget's window.  The source image is
29 rendered against a checkerboard, which provides a visual
30 representation of the alpha channel if the image has one. If the image
31 doesn't have an alpha channel, calling gdk_pixbuf_composite_color()
32 function has exactly the same effect as calling gdk_pixbuf_scale().
33 </para>
34
35 <programlisting>
36 gboolean
37 expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
38 {
39   GdkPixbuf *dest;
40
41   gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
42   
43   dest = gdk_pixbuf_new (ART_PIX_RGB, FALSE, 8, event->area.width, event->area.height);
44
45   gdk_pixbuf_composite_color (pixbuf, dest,
46                               0, 0, event->area.width, event->area.height,
47                               -event->area.x, -event->area.y,
48                               (double) widget->allocation.width / pixbuf->art_pixbuf->width,
49                               (double) widget->allocation.height / pixbuf->art_pixbuf->height,
50                               filter_level, 255,
51                                event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
52
53   gdk_pixbuf_render_to_drawable (dest, widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
54                                  0, 0, event->area.x, event->area.y,
55                                  event->area.width, event->area.height,
56                                  GDK_RGB_DITHER_NORMAL, event->area.x, event->area.y);
57   
58   gdk_pixbuf_unref (dest);
59   
60   return TRUE;
61 }
62 </programlisting>
63
64 <!-- ##### SECTION See_Also ##### -->
65 <para>
66
67 </para>
68
69 <!-- ##### FUNCTION gdk_pixbuf_scale ##### -->
70 <para>
71
72 </para>
73
74 @src: 
75 @dest: 
76 @dest_x: 
77 @dest_y: 
78 @dest_width: 
79 @dest_height: 
80 @offset_x: 
81 @offset_y: 
82 @scale_x: 
83 @scale_y: 
84 @filter_level: 
85
86
87 <!-- ##### FUNCTION gdk_pixbuf_composite ##### -->
88 <para>
89
90 </para>
91
92 @src: 
93 @dest: 
94 @dest_x: 
95 @dest_y: 
96 @dest_width: 
97 @dest_height: 
98 @offset_x: 
99 @offset_y: 
100 @scale_x: 
101 @scale_y: 
102 @filter_level: 
103 @overall_alpha: 
104
105
106 <!-- ##### FUNCTION gdk_pixbuf_composite_color ##### -->
107 <para>
108
109 </para>
110
111 @src: 
112 @dest: 
113 @dest_x: 
114 @dest_y: 
115 @dest_width: 
116 @dest_height: 
117 @offset_x: 
118 @offset_y: 
119 @scale_x: 
120 @scale_y: 
121 @filter_level: 
122 @overall_alpha: 
123 @check_x: 
124 @check_y: 
125 @check_size: 
126 @color1: 
127 @color2: 
128
129
130 <!-- ##### FUNCTION gdk_pixbuf_scale_simple ##### -->
131 <para>
132
133 </para>
134
135 @src: 
136 @dest_width: 
137 @dest_height: 
138 @filter_level: 
139 @Returns: 
140
141
142 <!-- ##### FUNCTION gdk_pixbuf_composite_color_simple ##### -->
143 <para>
144
145 </para>
146
147 @src: 
148 @dest_width: 
149 @dest_height: 
150 @filter_level: 
151 @overall_alpha: 
152 @check_size: 
153 @color1: 
154 @color2: 
155 @Returns: 
156
157 <!--
158 Local variables:
159 mode: sgml
160 sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
161 End:
162 -->