File: GdkRgb.xs

package info (click to toggle)
libgtk2-perl 2:1.2499-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,668 kB
  • ctags: 594
  • sloc: perl: 22,100; ansic: 122; makefile: 17
file content (233 lines) | stat: -rw-r--r-- 6,883 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*
 * Copyright (c) 2003 by the gtk2-perl team (see the file AUTHORS)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
 * Boston, MA  02111-1307  USA.
 *
 * $Id$
 */
 #include "gtk2perl.h"

/*
####MODULE = Gtk2::Gdk::Rgb	PACKAGE = Gtk2::Gdk::Drawable	PREFIX = gdk_

 ## no longer does anything, no need to bind it
##  void gdk_rgb_init (void) 

 ## deprecated
##  gulong gdk_rgb_xpixel_from_rgb (guint32 rgb) G_GNUC_CONST 
*/

static guchar *
SvImageDataPointer (SV * sv)
{
	if (gperl_sv_is_defined (sv)) {
		if (SvIOK (sv))
			return INT2PTR (guchar*, SvUV (sv));
		else if (SvPOK (sv))
			return (guchar *) SvPV_nolen (sv);
	}
	croak ("expecting either a string containing pixel data or "
	       "an integer pointing to the underlying C image data "
	       "buffer");
	return NULL; /* not reached */
}

static GdkRgbCmap *
SvGdkRgbCmap (SV *sv)
{
	GdkRgbCmap *cmap = NULL;
	AV *av;
	int length, i;

	if (!gperl_sv_is_array_ref (sv))
		croak ("cmap must be an array reference");

	av = (AV *) SvRV (sv);
	length = av_len (av);

	if (length > 255)
		croak ("a cmap may not consist of more than 256 colors");

	cmap = gperl_alloc_temp (sizeof (GdkRgbCmap));
	cmap->n_colors = length + 1;

	for (i = 0; i <= length; i++) {
		SV **color = av_fetch (av, i, 0);
		if (color && gperl_sv_is_defined (*color))
			cmap->colors[i] = SvIV (*color);
	}

	return cmap;
}

MODULE = Gtk2::Gdk::Rgb	PACKAGE = Gtk2::Gdk::GC	PREFIX = gdk_

##  void gdk_rgb_gc_set_foreground (GdkGC *gc, guint32 rgb) 
void gdk_rgb_gc_set_foreground (GdkGC * gc, guint32 rgb)
    ALIAS:
	Gtk2::Gdk::GC::set_rgb_foreground = 1
    CLEANUP:
	PERL_UNUSED_VAR (ix);

##  void gdk_rgb_gc_set_background (GdkGC *gc, guint32 rgb) 
void gdk_rgb_gc_set_background (GdkGC * gc, guint32 rgb)
    ALIAS:
	Gtk2::Gdk::GC::set_rgb_background = 1
    CLEANUP:
	PERL_UNUSED_VAR (ix);

MODULE = Gtk2::Gdk::Rgb	PACKAGE = Gtk2::Gdk::Colormap	PREFIX = gdk_

##  void gdk_rgb_find_color (GdkColormap *colormap, GdkColor *color) 
void gdk_rgb_find_color (GdkColormap *colormap, GdkColor *color)

MODULE = Gtk2::Gdk::Rgb	PACKAGE = Gtk2::Gdk::Drawable	PREFIX = gdk_

##  void gdk_draw_rgb_image (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint width, gint height, GdkRgbDither dith, guchar *rgb_buf, gint rowstride) 
##  void gdk_draw_rgb_32_image (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint width, gint height, GdkRgbDither dith, guchar *buf, gint rowstride) 
##  void gdk_draw_gray_image (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint width, gint height, GdkRgbDither dith, guchar *buf, gint rowstride) 
void
gdk_draw_rgb_image (drawable, gc, x, y, width, height, dith, buf, rowstride)
	GdkDrawable *drawable
	GdkGC *gc
	gint x
	gint y
	gint width
	gint height
	GdkRgbDither dith
	SV * buf
	gint rowstride
    ALIAS:
	draw_rgb_32_image = 1
	draw_gray_image = 2
    CODE:
	switch (ix) {
	    case 0:
		gdk_draw_rgb_image (drawable, gc, x, y, width, height,
		                    dith, SvImageDataPointer(buf),
		                    rowstride);
		break;
	    case 1:
		gdk_draw_rgb_32_image (drawable, gc, x, y, width, height,
		                       dith, SvImageDataPointer(buf),
		                       rowstride);
		break;
	    case 2:
		gdk_draw_gray_image (drawable, gc, x, y, width, height,
		                     dith, SvImageDataPointer(buf),
		                     rowstride);
		break;
	    default:
		g_assert_not_reached ();
	}

##  void gdk_draw_rgb_image_dithalign (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint width, gint height, GdkRgbDither dith, guchar *rgb_buf, gint rowstride, gint xdith, gint ydith) 
##  void gdk_draw_rgb_32_image_dithalign (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint width, gint height, GdkRgbDither dith, guchar *buf, gint rowstride, gint xdith, gint ydith) 
void
gdk_draw_rgb_image_dithalign (drawable, gc, x, y, width, height, dith, rgb_buf, rowstride, xdith, ydith)
	GdkDrawable *drawable
	GdkGC *gc
	gint x
	gint y
	gint width
	gint height
	GdkRgbDither dith
	SV *rgb_buf
	gint rowstride
	gint xdith
	gint ydith
    ALIAS:
	draw_rgb_32_image_dithalign = 1
    CODE:
	if (ix == 1)
		gdk_draw_rgb_32_image_dithalign (drawable, gc, x, y,
		                                 width, height, dith,
		                                 SvImageDataPointer (rgb_buf),
		                                 rowstride, xdith, ydith);
	else
		gdk_draw_rgb_image_dithalign (drawable, gc, x, y,
		                              width, height, dith,
		                              SvImageDataPointer(rgb_buf),
		                              rowstride, xdith, ydith);

##  void gdk_draw_indexed_image (GdkDrawable *drawable, GdkGC *gc, gint x, gint y, gint width, gint height, GdkRgbDither dith, guchar *buf, gint rowstride, GdkRgbCmap *cmap) 
void
gdk_draw_indexed_image (drawable, gc, x, y, width, height, dith, buf, rowstride, cmap)
	GdkDrawable *drawable
	GdkGC *gc
	gint x
	gint y
	gint width
	gint height
	GdkRgbDither dith
	SV *buf
	gint rowstride
	SV *cmap
    CODE:
	gdk_draw_indexed_image (drawable,
	                        gc,
	                        x,
	                        y,
	                        width,
	                        height,
	                        dith,
	                        SvImageDataPointer (buf),
	                        rowstride,
	                        SvGdkRgbCmap (cmap));

MODULE = Gtk2::Gdk::Rgb	PACKAGE = Gtk2::Gdk::Rgb	PREFIX = gdk_rgb_

##  void gdk_rgb_set_verbose (gboolean verbose) 
void
gdk_rgb_set_verbose (class, verbose)
	gboolean verbose
    C_ARGS:
	verbose

##  void gdk_rgb_set_install (gboolean install) 
void
gdk_rgb_set_install (class, install)
	gboolean install
    C_ARGS:
	install

##  void gdk_rgb_set_min_colors (gint min_colors) 
void
gdk_rgb_set_min_colors (class, min_colors)
	gint min_colors
    C_ARGS:
	min_colors

 ## no longer needed
##  GdkColormap *gdk_rgb_get_colormap (void) 
##  GdkVisual * gdk_rgb_get_visual (void) 

##  gboolean gdk_rgb_ditherable (void) 
gboolean
gdk_rgb_ditherable (class)
    C_ARGS:
	/*void*/

#if GTK_CHECK_VERSION (2, 6, 0)

##  gboolean gdk_rgb_colormap_ditherable (GdkColormap *cmap);
gboolean
gdk_rgb_colormap_ditherable (class, cmap)
	GdkColormap *cmap
    C_ARGS:
	cmap

#endif