gdk_pixbuf2 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/gdk_pixbuf2/rbgdk-pixbuf-format.c +49 -40
- data/ext/gdk_pixbuf2/rbgdk-pixbuf-loader.c +50 -40
- data/ext/gdk_pixbuf2/rbgdk-pixbuf.c +250 -168
- data/ext/gdk_pixbuf2/rbgdk-pixbuf.h +25 -18
- data/ext/gdk_pixbuf2/rbgdk-pixbuf2conversions.h +42 -0
- data/ext/gdk_pixbuf2/rbgdk-pixbuf2private.h +35 -0
- data/ext/gdk_pixbuf2/rbgdk-pixbufanimation.c +46 -83
- data/ext/gdk_pixbuf2/rbgdk-pixbufanimationiter.c +71 -0
- data/ext/gdk_pixbuf2/rbgdk-pixbufsimpleanim.c +29 -17
- data/ext/gdk_pixbuf2/rbgdk-pixdata.c +81 -77
- metadata +12 -10
- data/ChangeLog +0 -482
@@ -1,23 +1,33 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2004 Masao Mutoh
|
5
|
+
*
|
6
|
+
* This library is free software; you can redistribute it and/or
|
7
|
+
* modify it under the terms of the GNU Lesser General Public
|
8
|
+
* License as published by the Free Software Foundation; either
|
9
|
+
* version 2.1 of the License, or (at your option) any later version.
|
10
|
+
*
|
11
|
+
* This library is distributed in the hope that it will be useful,
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
* Lesser General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
17
|
+
* License along with this library; if not, write to the Free Software
|
18
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19
|
+
* MA 02110-1301 USA
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include "rbgdk-pixbuf2private.h"
|
13
23
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0)
|
14
24
|
|
15
25
|
#ifdef HAVE_GDK_PIXBUF_GDK_PIXBUF_IO_H
|
16
26
|
#include <gdk-pixbuf/gdk-pixbuf-io.h>
|
17
27
|
#endif
|
18
28
|
|
19
|
-
#define
|
20
|
-
|
29
|
+
#define RG_TARGET_NAMESPACE cPixbufFormat
|
30
|
+
#define _SELF(r) (RVAL2GDKPIXBUFFORMAT(r))
|
21
31
|
|
22
32
|
/**********************************/
|
23
33
|
static GdkPixbufFormat*
|
@@ -51,19 +61,19 @@ GSList* gdk_pixbuf_get_formats (void);
|
|
51
61
|
*/
|
52
62
|
|
53
63
|
static VALUE
|
54
|
-
|
64
|
+
rg_name(VALUE self)
|
55
65
|
{
|
56
66
|
return CSTR2RVAL_FREE(gdk_pixbuf_format_get_name(_SELF(self)));
|
57
67
|
}
|
58
68
|
|
59
69
|
static VALUE
|
60
|
-
|
70
|
+
rg_description(VALUE self)
|
61
71
|
{
|
62
72
|
return CSTR2RVAL_FREE(gdk_pixbuf_format_get_description(_SELF(self)));
|
63
73
|
}
|
64
|
-
|
74
|
+
|
65
75
|
static VALUE
|
66
|
-
|
76
|
+
rg_mime_types(VALUE self)
|
67
77
|
{
|
68
78
|
gint i = 0;
|
69
79
|
gchar** mime_types = gdk_pixbuf_format_get_mime_types(_SELF(self));
|
@@ -77,7 +87,7 @@ get_mime_types(VALUE self)
|
|
77
87
|
}
|
78
88
|
|
79
89
|
static VALUE
|
80
|
-
|
90
|
+
rg_extensions(VALUE self)
|
81
91
|
{
|
82
92
|
gint i = 0;
|
83
93
|
gchar** extensions = gdk_pixbuf_format_get_extensions(_SELF(self));
|
@@ -92,20 +102,20 @@ get_extensions(VALUE self)
|
|
92
102
|
}
|
93
103
|
|
94
104
|
static VALUE
|
95
|
-
|
105
|
+
rg_writable_p(VALUE self)
|
96
106
|
{
|
97
107
|
return CBOOL2RVAL(gdk_pixbuf_format_is_writable(_SELF(self)));
|
98
108
|
}
|
99
109
|
|
100
110
|
/* Structure */
|
101
111
|
static VALUE
|
102
|
-
|
112
|
+
rg_domain(VALUE self)
|
103
113
|
{
|
104
114
|
return CSTR2RVAL(_SELF(self)->domain);
|
105
115
|
}
|
106
116
|
|
107
117
|
static VALUE
|
108
|
-
|
118
|
+
rg_signature(VALUE self)
|
109
119
|
{
|
110
120
|
GdkPixbufModulePattern* signature = _SELF(self)->signature;
|
111
121
|
|
@@ -123,23 +133,23 @@ get_signature(VALUE self)
|
|
123
133
|
|
124
134
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,6,0)
|
125
135
|
static VALUE
|
126
|
-
|
136
|
+
rg_scalable_p(VALUE self)
|
127
137
|
{
|
128
138
|
return CBOOL2RVAL(gdk_pixbuf_format_is_scalable(_SELF(self)));
|
129
139
|
}
|
130
140
|
static VALUE
|
131
|
-
|
141
|
+
rg_disabled_p(VALUE self)
|
132
142
|
{
|
133
143
|
return CBOOL2RVAL(gdk_pixbuf_format_is_disabled(_SELF(self)));
|
134
144
|
}
|
135
145
|
static VALUE
|
136
|
-
|
146
|
+
rg_set_disabled(VALUE self, VALUE disabled)
|
137
147
|
{
|
138
148
|
gdk_pixbuf_format_set_disabled(_SELF(self), RVAL2CBOOL(disabled));
|
139
149
|
return self;
|
140
150
|
}
|
141
151
|
static VALUE
|
142
|
-
|
152
|
+
rg_license(VALUE self)
|
143
153
|
{
|
144
154
|
return CSTR2RVAL(gdk_pixbuf_format_get_license(_SELF(self)));
|
145
155
|
}
|
@@ -149,23 +159,22 @@ void
|
|
149
159
|
Init_gdk_pixbuf_format(VALUE mGdk)
|
150
160
|
{
|
151
161
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0)
|
152
|
-
VALUE
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
162
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXBUF_FORMAT, "PixbufFormat", mGdk);
|
163
|
+
|
164
|
+
RG_DEF_METHOD(name, 0);
|
165
|
+
RG_DEF_METHOD(description, 0);
|
166
|
+
RG_DEF_METHOD(mime_types, 0);
|
167
|
+
RG_DEF_METHOD(extensions, 0);
|
168
|
+
RG_DEF_METHOD_P(writable, 0);
|
169
|
+
RG_DEF_METHOD(domain, 0);
|
170
|
+
RG_DEF_METHOD(signature, 0);
|
161
171
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,6,0)
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
172
|
+
RG_DEF_METHOD_P(scalable, 0);
|
173
|
+
RG_DEF_METHOD_P(disabled, 0);
|
174
|
+
RG_DEF_METHOD(set_disabled, 1);
|
175
|
+
RG_DEF_METHOD(license, 0);
|
166
176
|
|
167
177
|
#endif
|
168
|
-
G_DEF_SETTERS(
|
178
|
+
G_DEF_SETTERS(RG_TARGET_NAMESPACE);
|
169
179
|
#endif
|
170
180
|
}
|
171
|
-
|
@@ -1,24 +1,35 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2004 Masao Mutoh
|
5
|
+
* Copyright (C) 2003 Geoff Youngs
|
6
|
+
*
|
7
|
+
* This library is free software; you can redistribute it and/or
|
8
|
+
* modify it under the terms of the GNU Lesser General Public
|
9
|
+
* License as published by the Free Software Foundation; either
|
10
|
+
* version 2.1 of the License, or (at your option) any later version.
|
11
|
+
*
|
12
|
+
* This library is distributed in the hope that it will be useful,
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
+
* Lesser General Public License for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public
|
18
|
+
* License along with this library; if not, write to the Free Software
|
19
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
20
|
+
* MA 02110-1301 USA
|
21
|
+
*/
|
22
|
+
|
23
|
+
#include "rbgdk-pixbuf2private.h"
|
24
|
+
|
25
|
+
#define RG_TARGET_NAMESPACE cPixbufLoader
|
26
|
+
#define _SELF(s) RVAL2GDKPIXBUFLOADER(s)
|
16
27
|
|
17
28
|
/****************************************************/
|
18
29
|
/* File opening */
|
19
30
|
/* Image Data in Memory */
|
20
31
|
static VALUE
|
21
|
-
|
32
|
+
rg_initialize(int argc, VALUE *argv, VALUE self)
|
22
33
|
{
|
23
34
|
GdkPixbufLoader* loader;
|
24
35
|
GError* error = NULL;
|
@@ -42,25 +53,25 @@ initialize_loader(int argc, VALUE *argv, VALUE self)
|
|
42
53
|
}
|
43
54
|
if(error) RAISE_GERROR(error);
|
44
55
|
}
|
45
|
-
|
56
|
+
|
46
57
|
G_INITIALIZE(self, loader);
|
47
58
|
return Qnil;
|
48
59
|
}
|
49
60
|
|
50
61
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0)
|
51
62
|
static VALUE
|
52
|
-
|
63
|
+
rg_format(VALUE self)
|
53
64
|
{
|
54
65
|
GdkPixbufFormat* format = gdk_pixbuf_loader_get_format(_SELF(self));
|
55
|
-
return
|
66
|
+
return GDKPIXBUFFORMAT2RVAL(format);
|
56
67
|
}
|
57
68
|
#endif
|
58
69
|
|
59
70
|
static VALUE
|
60
|
-
|
71
|
+
rg_write(VALUE self, VALUE data)
|
61
72
|
{
|
62
73
|
GError *error = NULL;
|
63
|
-
|
74
|
+
|
64
75
|
StringValue(data);
|
65
76
|
if (!gdk_pixbuf_loader_write(_SELF(self),
|
66
77
|
(const guchar *)RSTRING_PTR(data),
|
@@ -72,7 +83,7 @@ loader_write(VALUE self, VALUE data)
|
|
72
83
|
}
|
73
84
|
|
74
85
|
static VALUE
|
75
|
-
|
86
|
+
rg_last_write(VALUE self, VALUE data)
|
76
87
|
{
|
77
88
|
GError *error = NULL;
|
78
89
|
|
@@ -91,7 +102,7 @@ last_write(VALUE self, VALUE data)
|
|
91
102
|
|
92
103
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0)
|
93
104
|
static VALUE
|
94
|
-
|
105
|
+
rg_set_size(VALUE self, VALUE width, VALUE height)
|
95
106
|
{
|
96
107
|
gdk_pixbuf_loader_set_size(_SELF(self), NUM2INT(width), NUM2INT(height));
|
97
108
|
return self;
|
@@ -99,56 +110,55 @@ loader_set_size(VALUE self, VALUE width, VALUE height)
|
|
99
110
|
#endif
|
100
111
|
|
101
112
|
static VALUE
|
102
|
-
|
113
|
+
rg_close(VALUE self)
|
103
114
|
{
|
104
115
|
GError *error = NULL;
|
105
116
|
gboolean res;
|
106
|
-
|
117
|
+
|
107
118
|
res = gdk_pixbuf_loader_close(_SELF(self), &error);
|
108
119
|
if(error)
|
109
120
|
RAISE_GERROR(error);
|
110
|
-
|
121
|
+
|
111
122
|
return CBOOL2RVAL(res);
|
112
123
|
}
|
113
124
|
|
114
125
|
/****************************************************/
|
115
126
|
/* Creating image */
|
116
127
|
static VALUE
|
117
|
-
|
128
|
+
rg_pixbuf(VALUE self)
|
118
129
|
{
|
119
130
|
return GOBJ2RVAL(gdk_pixbuf_loader_get_pixbuf(_SELF(self)));
|
120
131
|
}
|
121
132
|
|
122
133
|
/* Creating animation */
|
123
134
|
static VALUE
|
124
|
-
|
135
|
+
rg_animation(VALUE self)
|
125
136
|
{
|
126
137
|
return GOBJ2RVAL(gdk_pixbuf_loader_get_animation(_SELF(self)));
|
127
138
|
}
|
128
139
|
|
129
|
-
|
130
140
|
void
|
131
141
|
Init_gdk_pixbuf_loader(VALUE mGdk)
|
132
142
|
{
|
133
|
-
VALUE
|
143
|
+
VALUE RG_TARGET_NAMESPACE;
|
134
144
|
/* initialize it */
|
135
|
-
|
145
|
+
RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXBUF_LOADER, "PixbufLoader", mGdk);
|
136
146
|
|
137
147
|
/*
|
138
148
|
* File Loading, Image Data in Memory
|
139
149
|
*/
|
140
|
-
|
150
|
+
RG_DEF_METHOD(initialize, -1);
|
141
151
|
|
142
|
-
rb_undef_method(
|
152
|
+
rb_undef_method(RG_TARGET_NAMESPACE, "dup");
|
143
153
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0)
|
144
|
-
|
154
|
+
RG_DEF_METHOD(format, 0);
|
145
155
|
#endif
|
146
|
-
|
147
|
-
|
156
|
+
RG_DEF_METHOD(write, 1);
|
157
|
+
RG_DEF_METHOD(last_write, 1);
|
148
158
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0)
|
149
|
-
|
159
|
+
RG_DEF_METHOD(set_size, 2);
|
150
160
|
#endif
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
}
|
161
|
+
RG_DEF_METHOD(close, 0);
|
162
|
+
RG_DEF_METHOD(pixbuf, 0);
|
163
|
+
RG_DEF_METHOD(animation, 0);
|
164
|
+
}
|
@@ -1,16 +1,26 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
2
|
+
/*
|
3
|
+
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
+
* Copyright (C) 2002-2004 Masao Mutoh
|
5
|
+
* Copyright (C) 2000 Yasushi Shoji
|
6
|
+
*
|
7
|
+
* This library is free software; you can redistribute it and/or
|
8
|
+
* modify it under the terms of the GNU Lesser General Public
|
9
|
+
* License as published by the Free Software Foundation; either
|
10
|
+
* version 2.1 of the License, or (at your option) any later version.
|
11
|
+
*
|
12
|
+
* This library is distributed in the hope that it will be useful,
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
+
* Lesser General Public License for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public
|
18
|
+
* License along with this library; if not, write to the Free Software
|
19
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
20
|
+
* MA 02110-1301 USA
|
21
|
+
*/
|
22
|
+
|
23
|
+
#include "rbgdk-pixbuf2private.h"
|
14
24
|
#include <string.h>
|
15
25
|
|
16
26
|
#ifdef HAVE_GDK_PIXBUF_GDK_PIXBUF_IO_H
|
@@ -18,7 +28,8 @@
|
|
18
28
|
#include <gdk-pixbuf/gdk-pixbuf-io.h>
|
19
29
|
#endif
|
20
30
|
|
21
|
-
#define
|
31
|
+
#define RG_TARGET_NAMESPACE cPixbuf
|
32
|
+
#define _SELF(s) RVAL2GDKPIXBUF(s)
|
22
33
|
|
23
34
|
#define NOMEM_ERROR(error) g_set_error(error,\
|
24
35
|
GDK_PIXBUF_ERROR,\
|
@@ -55,7 +66,7 @@ get_pixels(VALUE self)
|
|
55
66
|
}
|
56
67
|
|
57
68
|
static VALUE
|
58
|
-
|
69
|
+
rg_operator_set_pixels(VALUE self, VALUE pixels)
|
59
70
|
{
|
60
71
|
GdkPixbuf *pixbuf = _SELF(self);
|
61
72
|
int size;
|
@@ -79,7 +90,7 @@ set_pixels(VALUE self, VALUE pixels)
|
|
79
90
|
}
|
80
91
|
|
81
92
|
static VALUE
|
82
|
-
|
93
|
+
rg_get_option(VALUE self, VALUE key)
|
83
94
|
{
|
84
95
|
const gchar* ret = gdk_pixbuf_get_option(_SELF(self), RVAL2CSTR(key));
|
85
96
|
return ret ? CSTR2RVAL(ret) : Qnil;
|
@@ -88,30 +99,125 @@ get_option(VALUE self, VALUE key)
|
|
88
99
|
/****************************************************/
|
89
100
|
/* File opening */
|
90
101
|
/* Image Data in Memory */
|
91
|
-
static
|
92
|
-
|
102
|
+
static GdkPixbuf *
|
103
|
+
pixbuf_initialize_by_hash(VALUE self, VALUE arg, GError **error)
|
93
104
|
{
|
94
|
-
GdkPixbuf*
|
95
|
-
|
96
|
-
VALUE
|
105
|
+
GdkPixbuf *buf = NULL;
|
106
|
+
|
107
|
+
VALUE rb_colorspace, rb_has_alpha, rb_bits_per_sample, rb_width, rb_height,
|
108
|
+
rb_data, rb_rowstride, rb_xpm, rb_inline, rb_copy_pixels,
|
109
|
+
rb_src_pixbuf, rb_src_x, rb_src_y,
|
110
|
+
rb_file, rb_scale_width, rb_scale_height, rb_preserve_aspect_ratio;
|
111
|
+
rbg_scan_options(arg,
|
112
|
+
"colorspace", &rb_colorspace,
|
113
|
+
"has_alpha", &rb_has_alpha,
|
114
|
+
"bits_per_sample", &rb_bits_per_sample,
|
115
|
+
"width", &rb_width,
|
116
|
+
"height", &rb_height,
|
117
|
+
"data", &rb_data,
|
118
|
+
"rowstride", &rb_rowstride,
|
119
|
+
"xpm", &rb_xpm,
|
120
|
+
"inline", &rb_inline,
|
121
|
+
"copy_pixels", &rb_copy_pixels,
|
122
|
+
"src_pixbuf", &rb_src_pixbuf,
|
123
|
+
"src_x", &rb_src_x,
|
124
|
+
"src_y", &rb_src_y,
|
125
|
+
"file", &rb_file,
|
126
|
+
"scale_width", &rb_scale_width,
|
127
|
+
"scale_height", &rb_scale_height,
|
128
|
+
"preserve_aspect_ratio", &rb_preserve_aspect_ratio,
|
129
|
+
NULL);
|
130
|
+
|
131
|
+
if (!NIL_P(rb_data)) {
|
132
|
+
buf = gdk_pixbuf_new_from_data((const guchar*)RVAL2CSTR(rb_data),
|
133
|
+
NIL_P(rb_colorspace) ? GDK_COLORSPACE_RGB : RVAL2GDKCOLORSPACE(rb_colorspace),
|
134
|
+
RVAL2CBOOL(rb_has_alpha),
|
135
|
+
NIL_P(rb_bits_per_sample) ? 8 : NUM2INT(rb_bits_per_sample),
|
136
|
+
NUM2INT(rb_width),
|
137
|
+
NUM2INT(rb_height),
|
138
|
+
NUM2INT(rb_rowstride),
|
139
|
+
NULL, NULL);
|
140
|
+
if (buf == NULL)
|
141
|
+
NOMEM_ERROR(error);
|
142
|
+
// Save a reference to the string because the pixbuf doesn't copy it.
|
143
|
+
G_RELATIVE(self, rb_data);
|
144
|
+
} else if (!NIL_P(rb_xpm)) {
|
145
|
+
const gchar **data = RVAL2STRV(rb_xpm);
|
146
|
+
buf = gdk_pixbuf_new_from_xpm_data(data);
|
147
|
+
g_free(data);
|
148
|
+
if (buf == NULL)
|
149
|
+
NOMEM_ERROR(error);
|
150
|
+
} else if (!NIL_P(rb_inline)) {
|
151
|
+
/* TODO: Is this really up to the caller to decide? */
|
152
|
+
long n;
|
153
|
+
guint8 *data = RVAL2GUINT8S(rb_inline, n);
|
154
|
+
buf = gdk_pixbuf_new_from_inline(n, data, RVAL2CBOOL(rb_copy_pixels), error);
|
155
|
+
/* need to manage the returned value */
|
156
|
+
rb_ivar_set(self, id_pixdata, Data_Wrap_Struct(rb_cData, NULL, g_free, data));
|
157
|
+
} else if (!NIL_P(rb_src_pixbuf)) {
|
158
|
+
buf = gdk_pixbuf_new_subpixbuf(_SELF(rb_src_pixbuf),
|
159
|
+
NUM2INT(rb_src_x),
|
160
|
+
NUM2INT(rb_src_y),
|
161
|
+
NUM2INT(rb_width),
|
162
|
+
NUM2INT(rb_height));
|
163
|
+
if (buf == NULL)
|
164
|
+
NOMEM_ERROR(error);
|
165
|
+
} else if (!NIL_P(rb_file)) {
|
166
|
+
if (!NIL_P(rb_width)) {
|
167
|
+
#if RBGDK_PIXBUF_CHECK_VERSION(2,4,0)
|
168
|
+
buf = gdk_pixbuf_new_from_file_at_size(RVAL2CSTR(rb_file),
|
169
|
+
NUM2INT(rb_width),
|
170
|
+
NUM2INT(rb_height),
|
171
|
+
error);
|
172
|
+
#else
|
173
|
+
rb_warning("Sizing on load not supported in GTK+ < 2.4.0");
|
174
|
+
buf = gdk_pixbuf_new_from_file(RVAL2CSTR(rb_file), error);
|
175
|
+
#endif
|
176
|
+
} else if (!NIL_P(rb_scale_width)) {
|
177
|
+
#if RBGDK_PIXBUF_CHECK_VERSION(2,6,0)
|
178
|
+
int width = NUM2INT(rb_scale_width);
|
179
|
+
int height = NUM2INT(rb_scale_height);
|
180
|
+
#if !RBGDK_PIXBUF_CHECK_VERSION(2,8,0)
|
181
|
+
if (width < 0 || height < 0)
|
182
|
+
rb_warning("For scaling on load, a negative value for width or height are not supported in GTK+ < 2.8.0");
|
183
|
+
#endif
|
184
|
+
buf = gdk_pixbuf_new_from_file_at_scale(RVAL2CSTR(rb_file),
|
185
|
+
width, height,
|
186
|
+
NIL_P(rb_preserve_aspect_ratio) ? TRUE : RVAL2CBOOL(rb_preserve_aspect_ratio),
|
187
|
+
error);
|
188
|
+
#else
|
189
|
+
rb_warning("Scaling on load not supported in GTK+ < 2.6.0");
|
190
|
+
buf = gdk_pixbuf_new_from_file(RVAL2CSTR(rb_file), error);
|
191
|
+
#endif
|
192
|
+
} else {
|
193
|
+
buf = gdk_pixbuf_new_from_file(RVAL2CSTR(rb_file), error);
|
194
|
+
}
|
195
|
+
} else {
|
196
|
+
buf = gdk_pixbuf_new(NIL_P(rb_colorspace) ? GDK_COLORSPACE_RGB : RVAL2GDKCOLORSPACE(rb_colorspace),
|
197
|
+
RVAL2CBOOL(rb_has_alpha),
|
198
|
+
NIL_P(rb_bits_per_sample) ? 8 : NUM2INT(rb_bits_per_sample),
|
199
|
+
NUM2INT(rb_width),
|
200
|
+
NUM2INT(rb_height));
|
201
|
+
if (buf == NULL)
|
202
|
+
NOMEM_ERROR(error);
|
203
|
+
}
|
97
204
|
|
98
|
-
|
205
|
+
return buf;
|
206
|
+
}
|
207
|
+
|
208
|
+
/* TODO: make deprecated */
|
209
|
+
static GdkPixbuf *
|
210
|
+
pixbuf_initialize(VALUE self, int argc, VALUE arg1, VALUE arg2, VALUE arg3, VALUE arg4, VALUE arg5, VALUE arg6, VALUE arg7, GError **error)
|
211
|
+
{
|
212
|
+
GdkPixbuf* buf;
|
99
213
|
|
100
214
|
if (argc == 7){
|
101
215
|
buf = gdk_pixbuf_new_from_data((const guchar*)RVAL2CSTR(arg1),
|
102
|
-
|
216
|
+
RVAL2GDKCOLORSPACE(arg2),
|
103
217
|
RVAL2CBOOL(arg3), NUM2INT(arg4),
|
104
218
|
NUM2INT(arg5), NUM2INT(arg6),
|
105
219
|
NUM2INT(arg7), NULL, NULL);
|
106
|
-
if (buf == NULL)
|
107
|
-
rb_gc();
|
108
|
-
buf = gdk_pixbuf_new_from_data((const guchar*)RVAL2CSTR(arg1),
|
109
|
-
RVAL2GENUM(arg2, GDK_TYPE_COLORSPACE),
|
110
|
-
RVAL2CBOOL(arg3), NUM2INT(arg4),
|
111
|
-
NUM2INT(arg5), NUM2INT(arg6),
|
112
|
-
NUM2INT(arg7), NULL, NULL);
|
113
|
-
if (buf == NULL) NOMEM_ERROR(&error);
|
114
|
-
}
|
220
|
+
if (buf == NULL) NOMEM_ERROR(error);
|
115
221
|
// Save a reference to the string because the pixbuf doesn't copy it.
|
116
222
|
G_RELATIVE(self, arg1);
|
117
223
|
} else if (argc == 5){
|
@@ -119,24 +225,12 @@ initialize(int argc, VALUE *argv, VALUE self)
|
|
119
225
|
buf = gdk_pixbuf_new_subpixbuf(_SELF(arg1),
|
120
226
|
NUM2INT(arg2), NUM2INT(arg3),
|
121
227
|
NUM2INT(arg4), NUM2INT(arg5));
|
122
|
-
if (buf == NULL)
|
123
|
-
rb_gc();
|
124
|
-
buf = gdk_pixbuf_new_subpixbuf(_SELF(arg1),
|
125
|
-
NUM2INT(arg2), NUM2INT(arg3),
|
126
|
-
NUM2INT(arg4), NUM2INT(arg5));
|
127
|
-
if (buf == NULL) NOMEM_ERROR(&error);
|
128
|
-
}
|
228
|
+
if (buf == NULL) NOMEM_ERROR(error);
|
129
229
|
} else if (rb_obj_is_kind_of(arg1, GTYPE2CLASS(GDK_TYPE_COLORSPACE))){
|
130
|
-
buf = gdk_pixbuf_new(
|
230
|
+
buf = gdk_pixbuf_new(RVAL2GDKCOLORSPACE(arg1),
|
131
231
|
RVAL2CBOOL(arg2), NUM2INT(arg3),
|
132
232
|
NUM2INT(arg4), NUM2INT(arg5));
|
133
|
-
if (buf == NULL)
|
134
|
-
rb_gc();
|
135
|
-
buf = gdk_pixbuf_new(RVAL2GENUM(arg1, GDK_TYPE_COLORSPACE),
|
136
|
-
RVAL2CBOOL(arg2), NUM2INT(arg3),
|
137
|
-
NUM2INT(arg4), NUM2INT(arg5));
|
138
|
-
if (buf == NULL) NOMEM_ERROR(&error);
|
139
|
-
}
|
233
|
+
if (buf == NULL) NOMEM_ERROR(error);
|
140
234
|
} else {
|
141
235
|
rb_raise(rb_eArgError, "Wrong type of 1st argument or wrong number of arguments");
|
142
236
|
}
|
@@ -150,75 +244,38 @@ initialize(int argc, VALUE *argv, VALUE self)
|
|
150
244
|
#endif
|
151
245
|
buf = gdk_pixbuf_new_from_file_at_scale(RVAL2CSTR(arg1),
|
152
246
|
width, height,
|
153
|
-
RVAL2CBOOL(arg4),
|
154
|
-
if (buf == NULL){
|
155
|
-
rb_gc();
|
156
|
-
error = NULL;
|
157
|
-
buf = gdk_pixbuf_new_from_file_at_scale(RVAL2CSTR(arg1),
|
158
|
-
NUM2INT(arg2), NUM2INT(arg3),
|
159
|
-
RVAL2CBOOL(arg4), &error);
|
160
|
-
}
|
247
|
+
RVAL2CBOOL(arg4), error);
|
161
248
|
#else
|
162
249
|
rb_warning("Scaling on load not supported in GTK+ < 2.6.0");
|
163
|
-
buf = gdk_pixbuf_new_from_file(RVAL2CSTR(arg1),
|
164
|
-
if (buf == NULL){
|
165
|
-
error = NULL;
|
166
|
-
rb_gc();
|
167
|
-
buf = gdk_pixbuf_new_from_file(RVAL2CSTR(arg1), &error);
|
168
|
-
}
|
250
|
+
buf = gdk_pixbuf_new_from_file(RVAL2CSTR(arg1), error);
|
169
251
|
#endif
|
170
252
|
} else if (argc == 3) {
|
171
253
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,4,0)
|
172
254
|
buf = gdk_pixbuf_new_from_file_at_size(RVAL2CSTR(arg1),
|
173
|
-
NUM2INT(arg2), NUM2INT(arg3),
|
174
|
-
if (buf == NULL){
|
175
|
-
rb_gc();
|
176
|
-
error = NULL;
|
177
|
-
buf = gdk_pixbuf_new_from_file_at_size(RVAL2CSTR(arg1),
|
178
|
-
NUM2INT(arg2), NUM2INT(arg3), &error);
|
179
|
-
}
|
255
|
+
NUM2INT(arg2), NUM2INT(arg3), error);
|
180
256
|
#else
|
181
257
|
rb_warning("Sizing on load not supported in GTK+ < 2.4.0");
|
182
|
-
buf = gdk_pixbuf_new_from_file(RVAL2CSTR(arg1),
|
183
|
-
if (buf == NULL){
|
184
|
-
error = NULL;
|
185
|
-
rb_gc();
|
186
|
-
buf = gdk_pixbuf_new_from_file(RVAL2CSTR(arg1), &error);
|
187
|
-
}
|
258
|
+
buf = gdk_pixbuf_new_from_file(RVAL2CSTR(arg1), error);
|
188
259
|
#endif
|
189
|
-
} else if (argc == 2){
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
}
|
196
|
-
buf = gdk_pixbuf_new_from_inline(len, gstream, RVAL2CBOOL(arg2), &error);
|
197
|
-
if (buf == NULL){
|
198
|
-
rb_gc();
|
199
|
-
error = NULL;
|
200
|
-
buf = gdk_pixbuf_new_from_inline(len, gstream, RVAL2CBOOL(arg2), &error);
|
201
|
-
}
|
260
|
+
} else if (argc == 2) {
|
261
|
+
/* TODO: Is this really up to the caller to decide? */
|
262
|
+
gboolean copy_pixels = RVAL2CBOOL(arg2);
|
263
|
+
long n;
|
264
|
+
guint8 *data = RVAL2GUINT8S(arg1, n);
|
265
|
+
buf = gdk_pixbuf_new_from_inline(n, data, copy_pixels, error);
|
202
266
|
/* need to manage the returned value */
|
203
|
-
rb_ivar_set(self, id_pixdata, Data_Wrap_Struct(rb_cData, NULL, g_free,
|
267
|
+
rb_ivar_set(self, id_pixdata, Data_Wrap_Struct(rb_cData, NULL, g_free, data));
|
204
268
|
} else if (argc == 1){
|
205
269
|
if (TYPE(arg1) == T_STRING) {
|
206
|
-
buf = gdk_pixbuf_new_from_file(RVAL2CSTR(arg1),
|
207
|
-
if (buf == NULL){
|
208
|
-
rb_gc();
|
209
|
-
error = NULL;
|
210
|
-
buf = gdk_pixbuf_new_from_file(RVAL2CSTR(arg1), &error);
|
211
|
-
}
|
270
|
+
buf = gdk_pixbuf_new_from_file(RVAL2CSTR(arg1), error);
|
212
271
|
} else if (TYPE(arg1) == T_ARRAY) {
|
213
272
|
const gchar **data = RVAL2STRV(arg1);
|
214
273
|
buf = gdk_pixbuf_new_from_xpm_data(data);
|
215
|
-
if (buf == NULL) {
|
216
|
-
rb_gc();
|
217
|
-
buf = gdk_pixbuf_new_from_xpm_data(data);
|
218
|
-
}
|
219
274
|
g_free(data);
|
220
275
|
if (buf == NULL)
|
221
|
-
NOMEM_ERROR(
|
276
|
+
NOMEM_ERROR(error);
|
277
|
+
} else if (TYPE(arg1) == T_HASH) {
|
278
|
+
buf = pixbuf_initialize_by_hash(self, arg1, error);
|
222
279
|
} else {
|
223
280
|
rb_raise(rb_eArgError, "Wrong type of 1st argument or wrong number of arguments");
|
224
281
|
}
|
@@ -226,14 +283,33 @@ initialize(int argc, VALUE *argv, VALUE self)
|
|
226
283
|
rb_raise(rb_eArgError, "Wrong number of arguments");
|
227
284
|
}
|
228
285
|
|
229
|
-
|
230
|
-
|
286
|
+
return buf;
|
287
|
+
}
|
288
|
+
|
289
|
+
static VALUE
|
290
|
+
rg_initialize(int argc, VALUE *argv, VALUE self)
|
291
|
+
{
|
292
|
+
VALUE arg1, arg2, arg3, arg4, arg5, arg6, arg7;
|
293
|
+
GdkPixbuf *buf;
|
294
|
+
GError *error = NULL;
|
295
|
+
|
296
|
+
rb_scan_args(argc, argv, "16", &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7);
|
297
|
+
buf = pixbuf_initialize(self, argc, arg1, arg2, arg3, arg4, arg5, arg6, arg7, &error);
|
298
|
+
if (buf == NULL) {
|
299
|
+
rb_gc();
|
300
|
+
g_error_free(error);
|
301
|
+
error = NULL;
|
302
|
+
buf = pixbuf_initialize(self, argc, arg1, arg2, arg3, arg4, arg5, arg6, arg7, &error);
|
303
|
+
}
|
304
|
+
if (error || !buf)
|
305
|
+
RAISE_GERROR(error);
|
306
|
+
|
231
307
|
G_INITIALIZE(self, buf);
|
232
308
|
return Qnil;
|
233
309
|
}
|
234
310
|
|
235
311
|
static VALUE
|
236
|
-
|
312
|
+
rg_dup(VALUE self)
|
237
313
|
{
|
238
314
|
VALUE ret;
|
239
315
|
GdkPixbuf* dest = gdk_pixbuf_copy(_SELF(self));
|
@@ -246,13 +322,13 @@ copy(VALUE self)
|
|
246
322
|
|
247
323
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,4,0)
|
248
324
|
static VALUE
|
249
|
-
|
325
|
+
rg_s_get_file_info(G_GNUC_UNUSED VALUE self, VALUE filename)
|
250
326
|
{
|
251
327
|
gint width, height;
|
252
328
|
|
253
329
|
GdkPixbufFormat* format = gdk_pixbuf_get_file_info(RVAL2CSTR(filename),
|
254
330
|
&width, &height);
|
255
|
-
return format ? rb_ary_new3(3,
|
331
|
+
return format ? rb_ary_new3(3, GDKPIXBUFFORMAT2RVAL(format), INT2NUM(width), INT2NUM(height)) : Qnil;
|
256
332
|
}
|
257
333
|
|
258
334
|
#endif
|
@@ -315,7 +391,7 @@ save_to(VALUE self, const gchar *filename, const gchar *type, VALUE options)
|
|
315
391
|
/****************************************************/
|
316
392
|
/* File saving */
|
317
393
|
static VALUE
|
318
|
-
|
394
|
+
rg_save(int argc, VALUE *argv, VALUE self)
|
319
395
|
{
|
320
396
|
VALUE filename, type, options;
|
321
397
|
|
@@ -336,7 +412,7 @@ gboolean gdk_pixbuf_save_to_callbackv (GdkPixbuf *pixbuf,
|
|
336
412
|
*/
|
337
413
|
|
338
414
|
static VALUE
|
339
|
-
|
415
|
+
rg_save_to_buffer(int argc, VALUE *argv, VALUE self)
|
340
416
|
{
|
341
417
|
VALUE type, options;
|
342
418
|
|
@@ -349,7 +425,7 @@ save_to_buffer(int argc, VALUE *argv, VALUE self)
|
|
349
425
|
/****************************************************/
|
350
426
|
/* Scaling */
|
351
427
|
static VALUE
|
352
|
-
|
428
|
+
rg_scale(int argc, VALUE *argv, VALUE self)
|
353
429
|
{
|
354
430
|
GdkPixbuf* dest;
|
355
431
|
VALUE dest_width, dest_height, interp_type, ret;
|
@@ -359,8 +435,8 @@ scale_simple(int argc, VALUE *argv, VALUE self)
|
|
359
435
|
&interp_type);
|
360
436
|
|
361
437
|
if (!NIL_P(interp_type))
|
362
|
-
type =
|
363
|
-
|
438
|
+
type = RVAL2GDKINTERPTYPE(interp_type);
|
439
|
+
|
364
440
|
dest = gdk_pixbuf_scale_simple(_SELF(self),
|
365
441
|
NUM2INT(dest_width),
|
366
442
|
NUM2INT(dest_height),
|
@@ -374,7 +450,7 @@ scale_simple(int argc, VALUE *argv, VALUE self)
|
|
374
450
|
}
|
375
451
|
|
376
452
|
static VALUE
|
377
|
-
|
453
|
+
rg_scale_bang(int argc, VALUE *argv, VALUE self)
|
378
454
|
{
|
379
455
|
GdkInterpType type = GDK_INTERP_BILINEAR;
|
380
456
|
|
@@ -386,7 +462,7 @@ scale(int argc, VALUE *argv, VALUE self)
|
|
386
462
|
&scale_x, &scale_y, &interp_type);
|
387
463
|
|
388
464
|
if (!NIL_P(interp_type))
|
389
|
-
type =
|
465
|
+
type = RVAL2GDKINTERPTYPE(interp_type);
|
390
466
|
|
391
467
|
gdk_pixbuf_scale(_SELF(src), _SELF(self),
|
392
468
|
NUM2INT(src_x), NUM2INT(src_y),
|
@@ -397,14 +473,14 @@ scale(int argc, VALUE *argv, VALUE self)
|
|
397
473
|
}
|
398
474
|
|
399
475
|
static VALUE
|
400
|
-
|
476
|
+
rg_composite(VALUE self, VALUE dest_width, VALUE dest_height, VALUE interp_type, VALUE overall_alpha, VALUE check_size, VALUE color1, VALUE color2)
|
401
477
|
{
|
402
478
|
GdkPixbuf* dest;
|
403
479
|
VALUE ret;
|
404
480
|
GdkInterpType type = GDK_INTERP_BILINEAR;
|
405
481
|
|
406
482
|
if (!NIL_P(interp_type))
|
407
|
-
type =
|
483
|
+
type = RVAL2GDKINTERPTYPE(interp_type);
|
408
484
|
|
409
485
|
dest = gdk_pixbuf_composite_color_simple(
|
410
486
|
_SELF(self), NUM2INT(dest_width), NUM2INT(dest_height),
|
@@ -420,7 +496,7 @@ composite_simple(VALUE self, VALUE dest_width, VALUE dest_height, VALUE interp_t
|
|
420
496
|
}
|
421
497
|
|
422
498
|
static VALUE
|
423
|
-
|
499
|
+
rg_composite_bang(int argc, VALUE *argv, VALUE self)
|
424
500
|
{
|
425
501
|
VALUE ret;
|
426
502
|
VALUE args[16];
|
@@ -434,8 +510,8 @@ composite(int argc, VALUE *argv, VALUE self)
|
|
434
510
|
|
435
511
|
switch (argc) {
|
436
512
|
case 11:
|
437
|
-
|
438
|
-
|
513
|
+
if (!NIL_P(args[9]))
|
514
|
+
interp_type = RVAL2GDKINTERPTYPE(args[9]);
|
439
515
|
|
440
516
|
gdk_pixbuf_composite(_SELF(args[0]), _SELF(self),
|
441
517
|
NUM2INT(args[1]), NUM2INT(args[2]),
|
@@ -446,8 +522,8 @@ composite(int argc, VALUE *argv, VALUE self)
|
|
446
522
|
ret = self;
|
447
523
|
break;
|
448
524
|
case 16:
|
449
|
-
|
450
|
-
|
525
|
+
if (!NIL_P(args[9]))
|
526
|
+
interp_type = RVAL2GDKINTERPTYPE(args[9]);
|
451
527
|
|
452
528
|
gdk_pixbuf_composite_color(_SELF(args[0]), _SELF(self),
|
453
529
|
NUM2INT(args[1]), NUM2INT(args[2]),
|
@@ -461,18 +537,18 @@ composite(int argc, VALUE *argv, VALUE self)
|
|
461
537
|
ret = self;
|
462
538
|
break;
|
463
539
|
default:
|
464
|
-
|
465
|
-
|
540
|
+
rb_raise(rb_eArgError, "Wrong number of arguments: %d", argc);
|
541
|
+
break;
|
466
542
|
}
|
467
543
|
return ret;
|
468
544
|
}
|
469
545
|
|
470
546
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,6,0)
|
471
547
|
static VALUE
|
472
|
-
|
548
|
+
rg_rotate(VALUE self, VALUE angle)
|
473
549
|
{
|
474
550
|
VALUE ret;
|
475
|
-
GdkPixbuf* dest = gdk_pixbuf_rotate_simple(_SELF(self),
|
551
|
+
GdkPixbuf* dest = gdk_pixbuf_rotate_simple(_SELF(self), RVAL2GDKPIXBUFROTATION(angle));
|
476
552
|
if (dest == NULL)
|
477
553
|
return Qnil;
|
478
554
|
ret = GOBJ2RVAL(dest);
|
@@ -481,7 +557,7 @@ rotate_simple(VALUE self, VALUE angle)
|
|
481
557
|
}
|
482
558
|
|
483
559
|
static VALUE
|
484
|
-
|
560
|
+
rg_flip(VALUE self, VALUE horizontal)
|
485
561
|
{
|
486
562
|
VALUE ret;
|
487
563
|
GdkPixbuf* dest = gdk_pixbuf_flip(_SELF(self), RVAL2CBOOL(horizontal));
|
@@ -494,7 +570,7 @@ flip(VALUE self, VALUE horizontal)
|
|
494
570
|
#endif
|
495
571
|
|
496
572
|
static VALUE
|
497
|
-
|
573
|
+
rg_add_alpha(VALUE self, VALUE substitute_color, VALUE r, VALUE g, VALUE b)
|
498
574
|
{
|
499
575
|
VALUE ret;
|
500
576
|
GdkPixbuf* dest = gdk_pixbuf_add_alpha(_SELF(self),
|
@@ -508,7 +584,7 @@ add_alpha(VALUE self, VALUE substitute_color, VALUE r, VALUE g, VALUE b)
|
|
508
584
|
}
|
509
585
|
|
510
586
|
static VALUE
|
511
|
-
|
587
|
+
rg_copy_area(VALUE self, VALUE src_x, VALUE src_y, VALUE width, VALUE height, VALUE dest, VALUE dest_x, VALUE dest_y)
|
512
588
|
{
|
513
589
|
gdk_pixbuf_copy_area(_SELF(self), NUM2INT(src_x), NUM2INT(src_y),
|
514
590
|
NUM2INT(width), NUM2INT(height),
|
@@ -517,7 +593,7 @@ copy_area(VALUE self, VALUE src_x, VALUE src_y, VALUE width, VALUE height, VALUE
|
|
517
593
|
}
|
518
594
|
|
519
595
|
static VALUE
|
520
|
-
|
596
|
+
rg_saturate_and_pixelate(VALUE self, VALUE staturation, VALUE pixelate)
|
521
597
|
{
|
522
598
|
GdkPixbuf* dest = gdk_pixbuf_copy(_SELF(self));
|
523
599
|
gdk_pixbuf_saturate_and_pixelate(_SELF(self), dest,
|
@@ -526,7 +602,7 @@ saturate_and_pixelate(VALUE self, VALUE staturation, VALUE pixelate)
|
|
526
602
|
}
|
527
603
|
|
528
604
|
static VALUE
|
529
|
-
|
605
|
+
rg_fill_bang(VALUE self, VALUE pixel)
|
530
606
|
{
|
531
607
|
gdk_pixbuf_fill(_SELF(self), NUM2UINT(pixel));
|
532
608
|
return self;
|
@@ -535,35 +611,40 @@ fill(VALUE self, VALUE pixel)
|
|
535
611
|
/* From Module Interface */
|
536
612
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0)
|
537
613
|
static VALUE
|
538
|
-
|
614
|
+
rg_s_formats(G_GNUC_UNUSED VALUE self)
|
539
615
|
{
|
540
616
|
return GSLIST2ARY2(gdk_pixbuf_get_formats(), GDK_TYPE_PIXBUF_FORMAT);
|
541
617
|
}
|
542
618
|
|
619
|
+
#ifdef HAVE_GDK_PIXBUF_SET_OPTION
|
543
620
|
static VALUE
|
544
|
-
|
621
|
+
rg_set_option(VALUE self, VALUE key, VALUE value)
|
545
622
|
{
|
546
|
-
|
547
|
-
return CBOOL2RVAL(gdk_pixbuf_set_option(_SELF(self),
|
623
|
+
return CBOOL2RVAL(gdk_pixbuf_set_option(_SELF(self),
|
548
624
|
RVAL2CSTR(key), RVAL2CSTR(value)));
|
625
|
+
}
|
549
626
|
#else
|
627
|
+
static VALUE
|
628
|
+
set_option(G_GNUC_UNUSED VALUE self, G_GNUC_UNUSED VALUE key, G_GNUC_UNUSED VALUE value)
|
629
|
+
{
|
550
630
|
rb_warning("not supported in this version of GTK+");
|
551
631
|
return Qfalse;
|
552
|
-
#endif
|
553
632
|
}
|
554
633
|
#endif
|
634
|
+
#endif
|
635
|
+
|
636
|
+
extern void Init_gdk_pixbuf2(void);
|
555
637
|
|
556
|
-
void
|
557
|
-
Init_gdk_pixbuf2()
|
638
|
+
void
|
639
|
+
Init_gdk_pixbuf2(void)
|
558
640
|
{
|
559
641
|
VALUE mGdk = rb_define_module("Gdk");
|
560
|
-
VALUE
|
642
|
+
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_PIXBUF, "Pixbuf", mGdk);
|
561
643
|
|
562
644
|
id_pixdata = rb_intern("pixdata");
|
563
|
-
|
645
|
+
|
564
646
|
/*
|
565
647
|
gdk_rgb_init();*/ /* initialize it anyway */
|
566
|
-
|
567
648
|
|
568
649
|
/*
|
569
650
|
* Initialization and Versions
|
@@ -571,86 +652,87 @@ Init_gdk_pixbuf2()
|
|
571
652
|
/* Removed. This crashes Ruby/GTK on Windows + GTK+-2.4.x.
|
572
653
|
Pointed out by Laurent.
|
573
654
|
#ifdef HAVE_GDK_PIXBUF_VERSION
|
574
|
-
rb_define_const(
|
655
|
+
rb_define_const(RG_TARGET_NAMESPACE, "VERSION", CSTR2RVAL(gdk_pixbuf_version));
|
575
656
|
#endif
|
576
657
|
*/
|
577
|
-
rb_define_const(
|
578
|
-
rb_define_const(
|
579
|
-
rb_define_const(
|
658
|
+
rb_define_const(RG_TARGET_NAMESPACE, "MAJOR", INT2FIX(GDK_PIXBUF_MAJOR));
|
659
|
+
rb_define_const(RG_TARGET_NAMESPACE, "MINOR", INT2FIX(GDK_PIXBUF_MINOR));
|
660
|
+
rb_define_const(RG_TARGET_NAMESPACE, "MICRO", INT2FIX(GDK_PIXBUF_MICRO));
|
580
661
|
|
581
662
|
/*
|
582
663
|
* The GdkPixbuf Structure
|
583
664
|
*/
|
584
|
-
G_REPLACE_GET_PROPERTY(
|
585
|
-
|
586
|
-
|
665
|
+
G_REPLACE_GET_PROPERTY(RG_TARGET_NAMESPACE, "pixels", get_pixels, 0);
|
666
|
+
RG_DEF_METHOD_OPERATOR("pixels=", set_pixels, 1);
|
667
|
+
RG_DEF_METHOD(get_option, 1);
|
587
668
|
|
588
669
|
/* GdkPixbufError */
|
589
670
|
G_DEF_ERROR(GDK_PIXBUF_ERROR, "PixbufError", mGdk, rb_eRuntimeError, GDK_TYPE_PIXBUF_ERROR);
|
590
671
|
|
591
672
|
/* GdkColorspace */
|
592
|
-
G_DEF_CLASS(GDK_TYPE_COLORSPACE, "ColorSpace",
|
593
|
-
G_DEF_CONSTANTS(
|
673
|
+
G_DEF_CLASS(GDK_TYPE_COLORSPACE, "ColorSpace", RG_TARGET_NAMESPACE);
|
674
|
+
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_COLORSPACE, "GDK_");
|
594
675
|
|
595
676
|
/* GdkPixbufAlphaMode */
|
596
|
-
G_DEF_CLASS(GDK_TYPE_PIXBUF_ALPHA_MODE, "AlphaMode",
|
597
|
-
G_DEF_CONSTANTS(
|
677
|
+
G_DEF_CLASS(GDK_TYPE_PIXBUF_ALPHA_MODE, "AlphaMode", RG_TARGET_NAMESPACE);
|
678
|
+
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_PIXBUF_ALPHA_MODE, "GDK_PIXBUF_");
|
598
679
|
|
599
680
|
/*
|
600
681
|
* File Loading, Image Data in Memory
|
601
682
|
*/
|
602
|
-
|
603
|
-
|
683
|
+
RG_DEF_METHOD(initialize, -1);
|
684
|
+
RG_DEF_METHOD(dup, 0);
|
604
685
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,4,0)
|
605
|
-
|
686
|
+
RG_DEF_SMETHOD(get_file_info, 1);
|
606
687
|
#endif
|
607
688
|
|
608
689
|
/*
|
609
690
|
* File saving
|
610
691
|
*/
|
611
|
-
|
692
|
+
RG_DEF_METHOD(save, -1);
|
612
693
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,4,0)
|
613
|
-
|
694
|
+
RG_DEF_METHOD(save_to_buffer, -1);
|
614
695
|
#endif
|
615
696
|
|
616
697
|
/*
|
617
698
|
* Scaling
|
618
699
|
*/
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
700
|
+
RG_DEF_METHOD(scale, -1);
|
701
|
+
RG_DEF_METHOD_BANG(scale, -1);
|
702
|
+
RG_DEF_METHOD(composite, 7);
|
703
|
+
RG_DEF_METHOD_BANG(composite, -1);
|
623
704
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,6,0)
|
624
|
-
|
625
|
-
|
705
|
+
RG_DEF_METHOD(rotate, 1);
|
706
|
+
RG_DEF_METHOD(flip, 1);
|
626
707
|
#endif
|
627
708
|
|
628
709
|
/* GdkInterpType */
|
629
|
-
G_DEF_CLASS(GDK_TYPE_INTERP_TYPE, "InterpType",
|
630
|
-
G_DEF_CONSTANTS(
|
710
|
+
G_DEF_CLASS(GDK_TYPE_INTERP_TYPE, "InterpType", RG_TARGET_NAMESPACE);
|
711
|
+
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_INTERP_TYPE, "GDK_");
|
631
712
|
|
632
713
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,6,0)
|
633
714
|
/* GdkPixbufRotation */
|
634
|
-
G_DEF_CLASS(GDK_TYPE_PIXBUF_ROTATION, "GdkPixbufRotation",
|
635
|
-
G_DEF_CONSTANTS(
|
715
|
+
G_DEF_CLASS(GDK_TYPE_PIXBUF_ROTATION, "GdkPixbufRotation", RG_TARGET_NAMESPACE);
|
716
|
+
G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, GDK_TYPE_PIXBUF_ROTATION, "GDK_PIXBUF_");
|
636
717
|
#endif
|
637
718
|
/*
|
638
719
|
* Utilities
|
639
720
|
*/
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
721
|
+
RG_DEF_METHOD(add_alpha, 4);
|
722
|
+
RG_DEF_METHOD(copy_area, 7);
|
723
|
+
RG_DEF_METHOD(saturate_and_pixelate, 2);
|
724
|
+
RG_DEF_METHOD_BANG(fill, 1);
|
644
725
|
|
645
726
|
/*
|
646
727
|
* Module Interface
|
647
728
|
*/
|
648
729
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,2,0)
|
649
|
-
|
650
|
-
|
730
|
+
RG_DEF_SMETHOD(formats, 0);
|
731
|
+
RG_DEF_METHOD(set_option, 2);
|
651
732
|
#endif
|
652
733
|
|
653
734
|
Init_gdk_pixbuf_animation(mGdk);
|
735
|
+
Init_gdk_pixbuf_animation_iter(mGdk);
|
654
736
|
#if RBGDK_PIXBUF_CHECK_VERSION(2,8,0)
|
655
737
|
Init_gdk_pixbuf_simpleanim(mGdk);
|
656
738
|
#endif
|