1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4 #include <X11/Xlib.h>
5 #include <Imlib2.h>
6 #include "Imlib2Types.h"
7 
8 MODULE = Imlib2		PACKAGE = Imlib2 	PREFIX = imlib_
9 
10 Imlib2::Imlib_Image
11 load_image(file)
12 	char *file
13 	CODE:
14 	RETVAL = imlib_load_image(file);
15 	OUTPUT:
16 	RETVAL
17 
18 Imlib2::Imlib_Image
create_image_using_data(w,h,data)19 create_image_using_data(w,h,data)
20     	int w
21   	int h
22   	DATA32 *data
23   	CODE:
24 	{
25 /*		if (!data) croak("Data must be a reference!\n");*/
26 		RETVAL = imlib_create_image_using_data(w,h,data);
27 	}
28 	OUTPUT:
29 	RETVAL
30 
31 DATA32 *
32 image_get_data()
33     	CODE:
34 	RETVAL = imlib_image_get_data();
35 	OUTPUT:
36 	RETVAL
37 
38 DATA32 *
39 image_put_back_data(data)
40 	DATA32 *data
41 	CODE:
42 	imlib_image_put_back_data(data);
43 
44 DATA32 *
45 image_get_data_for_reading_only()
46 	CODE:
47 	RETVAL = imlib_image_get_data_for_reading_only();
48 	OUTPUT:
49 	RETVAL
50 
51 
52 void
53 save_image(file)
54 	char *file
55 	CODE:
56        	imlib_save_image(file);
57 
58 
59 void
60 set_context(image)
61 	Imlib2::Imlib_Image image
62 	CODE:
63 	imlib_context_set_image(image);
64 
65 void
66 free_image()
67 	CODE:
68 	imlib_free_image();
69 
70 void
71 free_image_and_decache()
72 	CODE:
73 	imlib_free_image_and_decache();
74 
75 
76 void
77 blend_image_onto_image(source_image, merge_alpha, source_x, source_y, source_width,source_height, destination_x, destination_y, destination_width,destination_height)
78 	Imlib2::Imlib_Image source_image
79 	char merge_alpha
80 	int source_x
81 	int source_y
82 	int source_height
83 	int source_width
84 	int destination_x
85 	int destination_y
86 	int destination_width
87 	int destination_height
88 	CODE:
89 	imlib_blend_image_onto_image(source_image, merge_alpha, source_x, source_y, source_width,source_height, destination_x, destination_y, destination_width,destination_height);
90 
91 int
92 get_width()
93 	CODE:
94 	RETVAL = imlib_image_get_width();
95 	OUTPUT:
96 	RETVAL
97 
98 int
99 get_height()
100 	CODE:
101 	RETVAL = imlib_image_get_height();
102 	OUTPUT:
103 	RETVAL
104 
105 const char *
106 get_filename()
107 	CODE:
108 	RETVAL = imlib_image_get_filename();
109 	OUTPUT:
110 	RETVAL
111 
112 Imlib2::Imlib_Image
113 create_image(w, h)
114 	int w
115 	int h
116 	CODE:
117 	RETVAL = imlib_create_image(w, h);
118 	OUTPUT:
119 	RETVAL
120 
121 Imlib2::Imlib_Image
122 create_image_from_drawable(mask,x,y,w,h,grab_x)
123 	Imlib2::Pixmap mask
124 	int x
125 	int y
126 	int w
127 	int h
128 	char grab_x
129 	CODE:
130 	RETVAL = imlib_create_image_from_drawable(mask,x,y,w,h,grab_x);
131 	OUTPUT:
132 	RETVAL
133 
134 void
render_pixmaps_for_whole_image()135 render_pixmaps_for_whole_image()
136 	PPCODE:
137 	{
138 		Pixmap pixmap,mask;
139 		imlib_render_pixmaps_for_whole_image(&pixmap,&mask);
140 		EXTEND(sp,2);
141 		PUSHs(sv_2mortal(newSVuv(pixmap)));
142 		PUSHs(sv_2mortal(newSVuv(mask)));
143 	}
144 
145 void
render_pixmaps_for_whole_image_at_size(x,y)146 render_pixmaps_for_whole_image_at_size(x,y)
147 	int x
148 	int y
149 	PPCODE:
150 	{
151 		Pixmap pixmap,mask;
152 		imlib_render_pixmaps_for_whole_image_at_size(&pixmap,&mask,x,y);
153 		EXTEND(sp,2);
154 		PUSHs(sv_2mortal(newSVuv(pixmap)));
155 		PUSHs(sv_2mortal(newSVuv(mask)));
156 	}
157 
158 
159 void
160 free_pixmap_and_mask(pixmap)
161     	Imlib2::Pixmap pixmap
162   	CODE:
163 	imlib_free_pixmap_and_mask(pixmap);
164 
165 Imlib2::Pixmap
166 context_get_mask()
167     	CODE:
168 	RETVAL = imlib_context_get_mask();
169 	OUTPUT:
170 	RETVAL
171 
172 void
173 context_set_drawable(drawable)
174 	Imlib2::Drawable drawable
175 	CODE:
176 	imlib_context_set_drawable(drawable);
177 
178 void
179 render_image_on_drawable(x,y)
180 	int x
181 	int y
182 	CODE:
183 	imlib_render_image_on_drawable(x,y);
184 
185 
186 void
187 render_image_on_drawable_at_size(x,y,width,height)
188 	int x
189 	int y
190 	int width
191 	int height
192 	CODE:
193 	imlib_render_image_on_drawable_at_size(x,y,width,height);
194 
195 
196 void
197 context_set_colormap(colormap)
198 	Imlib2::Colormap colormap
199 	CODE:
200 	imlib_context_set_colormap(colormap);
201 
202 void
203 context_set_display(display)
204 	Imlib2::Display display
205 	CODE:
206 	imlib_context_set_display(display);
207 
208 void
209 context_set_visual(visual)
210 	Imlib2::Visual visual
211 	CODE:
212 	imlib_context_set_visual(visual);
213 
214 void
215 context_set_dither_mask(dither_mask)
216     	char dither_mask
217  	CODE:
218 	imlib_context_set_dither_mask(dither_mask);
219 
220 void
221 context_set_anti_alias(anti_alias)
222     	char anti_alias
223   	CODE:
224 	imlib_context_set_anti_alias(anti_alias);
225 
226 void
227 context_set_blend(blend)
228     	char blend
229   	CODE:
230 	imlib_context_set_blend(blend);
231 
232 void
233 context_set_angle(angle)
234     	double angle
235   	CODE:
236 	imlib_context_set_angle(angle);
237 
238 void
239 context_set_color(red,green,blue,alpha)
240     	int red
241   	int green
242   	int blue
243   	int alpha
244         CODE:
245 	imlib_context_set_color(red,green,blue,alpha);
246 
247 void
248 context_set_dither(dither)
249     	char dither
250  	CODE:
251 	imlib_context_set_dither(dither);
252 
253 int
254 get_cache_size()
255 	CODE:
256 	RETVAL = imlib_get_cache_size();
257 	OUTPUT:
258 	RETVAL
259 
260 void
261 set_cache_size(bytes)
262     	int bytes
263   	CODE:
264 	imlib_set_cache_size(bytes);
265 
266 int
267 image_has_alpha()
268     	CODE:
269 	RETVAL = imlib_image_has_alpha();
270 	OUTPUT:
271 	RETVAL
272 
273 Imlib2::Imlib_Image
274 clone_image()
275     	CODE:
276 	RETVAL = imlib_clone_image();
277   	OUTPUT:
278 	RETVAL
279 
280 Imlib2::Imlib_Image
281 create_cropped_image(x,y,width,height)
282     	int x
283   	int y
284   	int width
285   	int height
286   	CODE:
287 	RETVAL = imlib_create_cropped_image(x,y,width,height);
288 	OUTPUT:
289 	RETVAL
290 
291 Imlib2::Imlib_Image
292 create_cropped_scaled_image(source_x,source_y,source_width,source_height,destination_width,destination_height)
293     	int source_x
294   	int source_y
295   	int source_width
296   	int source_height
297   	int destination_width
298   	int destination_height
299   	CODE:
300 	RETVAL = imlib_create_cropped_scaled_image(source_x,source_y,source_width,source_height,destination_width,destination_height);
301 	OUTPUT:
302 	RETVAL
303 
304 void
305 flip_horizontal()
306     	CODE:
307 	imlib_image_flip_horizontal();
308 
309 void
310 flip_vertical()
311     	CODE:
312 	imlib_image_flip_vertical();
313 
314 void
315 flip_diagonal()
316     	CODE:
317 	imlib_image_flip_diagonal();
318 
319 void
320 orientate(orientation)
321     	int orientation
322         CODE:
323 	imlib_image_orientate(orientation);
324 
325 void
326 blur(radius)
327     	int radius
328   	CODE:
329 	imlib_image_blur(radius);
330 
331 void
332 sharpen(radius)
333     	int radius
334   	CODE:
335 	imlib_image_sharpen(radius);
336 
337 void
338 tile()
339     	CODE:
340 	imlib_image_tile();
341 
342 void
343 tile_vertical()
344     	CODE:
345 	imlib_image_tile_vertical();
346 
347 void
348 tile_horizontal()
349 	CODE:
350 	imlib_image_tile_horizontal();
351 
352 void
353 context_set_font(font)
354 	Imlib2::Imlib_Font font
355 	CODE:
356 	imlib_context_set_font(font);
357 
358 Imlib2::Imlib_Font
359 context_get_font()
360 	CODE:
361 	RETVAL = imlib_context_get_font();
362 	OUTPUT:
363 	RETVAL
364 
365 Imlib2::Imlib_Font
366 load_font(fontname)
367 	char *fontname
368 	CODE:
369 	RETVAL = imlib_load_font(fontname);
370 	OUTPUT:
371 	RETVAL
372 
373 void
374 free_font()
375 	CODE:
376 	imlib_free_font();
377 
378 void
379 text_draw(x,y,text)
380 	int x
381 	int y
382 	char *text
383 	CODE:
384 	imlib_text_draw(x,y,text);
385 
386 
387 void
get_text_size(text)388 get_text_size(text)
389 	const char *text
390 	PPCODE:
391 	{
392 		int text_w;
393 		int text_h;
394 		imlib_get_text_size(text,&text_w,&text_h);
395 		EXTEND(sp,2);
396 		PUSHs(sv_2mortal(newSViv(text_w)));
397 		PUSHs(sv_2mortal(newSViv(text_h)));
398 	}
399 
400 
401 void
402 add_path_to_font_path(path)
403 	char *path
404 	CODE:
405 	imlib_add_path_to_font_path(path);
406 
407 void
408 context_set_direction(direction)
409 	int direction;
410 	CODE:
411 	imlib_context_set_direction(direction);
412 
413 void
414 context_set_color_modifier(modifier)
415 	Imlib2::Imlib_Color_Modifier modifier
416 	CODE:
417 	imlib_context_set_color_modifier(modifier);
418 
419 Imlib2::Imlib_Color_Modifier
420 context_get_color_modifier()
421 	CODE:
422 	RETVAL = imlib_context_get_color_modifier();
423 	OUTPUT:
424 	RETVAL
425 
426 Imlib2::Imlib_Color_Modifier
427 create_color_modifier()
428 	CODE:
429 	RETVAL = imlib_create_color_modifier();
430 	OUTPUT:
431 	RETVAL
432 
433 void
434 free_color_modifier()
435 	CODE:
436 	imlib_free_color_modifier();
437 
438 void
439 modify_color_modifier_gamma(gamma_value)
440 	double gamma_value
441 	CODE:
442 	imlib_modify_color_modifier_gamma(gamma_value);
443 
444 void
445 modify_color_modifier_brightness(brightness_value)
446 	double brightness_value
447 	CODE:
448 	imlib_modify_color_modifier_brightness(brightness_value);
449 
450 void
451 modify_color_modifier_contrast(contrast_value)
452 	double contrast_value
453 	CODE:
454 	imlib_modify_color_modifier_contrast(contrast_value);
455 
456 void
457 reset_color_modifier()
458 	CODE:
459 	imlib_reset_color_modifier();
460 
461 void
462 apply_color_modifier()
463 	CODE:
464 	imlib_apply_color_modifier();
465 
466 void
467 apply_color_modifier_to_rectangle(x,y,width,height)
468 	int x
469 	int y
470 	int width
471 	int height
472 	CODE:
473 	imlib_apply_color_modifier_to_rectangle(x,y,width,height);
474 
475 void
476 draw_line(x1,y1,x2,y2)
477 	int x1
478 	int y1
479 	int x2
480 	int y2
481 	CODE:
482 	imlib_image_draw_line(x1,y1,x2,y2,0);
483 
484 void
485 draw_rectangle(x,y,width,height)
486 	int x
487 	int y
488 	int width
489 	int height
490 	CODE:
491 	imlib_image_draw_rectangle(x,y,width,height);
492 
493 void
494 fill_rectangle(x,y,width,height)
495 	int x
496 	int y
497 	int width
498 	int height
499 	CODE:
500 	imlib_image_fill_rectangle(x,y,width,height);
501 
502 void
503 copy_alpha_to_image(image_source, x, y)
504 	Imlib2::Imlib_Image image_source
505 	int x
506 	int y
507 	CODE:
508 	imlib_image_copy_alpha_to_image(image_source,x,y);
509 
510 void
511 copy_alpha_rectangle_to_image(image_source,x,y,width,height,destination_x,destination_y)
512 	Imlib2::Imlib_Image image_source
513 	int x
514 	int y
515 	int width
516 	int height
517 	int destination_x
518 	int destination_y
519 	CODE:
520 	imlib_image_copy_alpha_rectangle_to_image(image_source,x,y,width,height,destination_x,destination_y);
521 
522 void
523 scroll_rect(x,y,width,height,delta_x,delta_y)
524 	int x
525 	int y
526 	int width
527 	int height
528 	int delta_x
529 	int delta_y
530 	CODE:
531 	imlib_image_scroll_rect(x,y,width,height,delta_x,delta_y);
532 
533 void
534 copy_rect(x,y,width,height,new_x,new_y)
535 	int x
536 	int y
537 	int width
538 	int height
539 	int new_x
540 	int new_y
541 	CODE:
542 	imlib_image_copy_rect(x,y,width,height,new_x,new_y);
543 
544 void
545 draw_ellipse(xc,yc,a,b)
546 	int xc
547 	int yc
548 	int a
549 	int b
550 	CODE:
551 	imlib_image_draw_ellipse(xc,yc,a,b);
552 
553 void
554 fill_ellipse(xc,yc,a,b)
555 	int xc
556 	int yc
557 	int a
558 	int b
559 	CODE:
560 	imlib_image_fill_ellipse(xc,yc,a,b);
561 
562 void
563 context_set_color_range(color_range)
564 	Imlib2::Imlib_Color_Range	color_range
565 	CODE:
566 	imlib_context_set_color_range(color_range);
567 
568 Imlib2::Imlib_Color_Range
569 get_color_range()
570 	CODE:
571 	imlib_context_get_color_range();
572 
573 Imlib2::Imlib_Color_Range
574 create_color_range()
575 	CODE:
576 	RETVAL = imlib_create_color_range();
577 	OUTPUT:
578 	RETVAL
579 
580 void
581 free_color_range()
582 	CODE:
583 	imlib_free_color_range();
584 
585 void
586 add_color_to_color_range(distance_away)
587 	int distance_away
588 	CODE:
589 	imlib_add_color_to_color_range(distance_away);
590 
591 void
592 fill_color_range_rectangle(x,y,width,height,angle)
593 	int x
594 	int y
595 	int width
596 	int height
597 	double angle
598 	CODE:
599 	imlib_image_fill_color_range_rectangle(x,y,width,height,angle);
600 
601 void
602 set_format(format)
603 	char *format
604 	CODE:
605 	imlib_image_set_format(format);
606 
607