source: libpipi/trunk/pipi-php/php_pipi.c @ 3069

Last change on this file since 3069 was 3069, checked in by nico, 12 years ago

Initial release of pipi-php

File size: 16.7 KB
Line 
1/*
2 *  php-pipi      Php binding for Libpipi
3 *  Copyright (c) 2008 Vion Nicolas <nico@picapo.net>
4 *
5 *
6 *  This library is free software. It comes without any warranty, to
7 *  the extent permitted by applicable law. You can redistribute it
8 *  and/or modify it under the terms of the Do What The Fuck You Want
9 *  To Public License, Version 2, as published by Sam Hocevar. See
10 *  http://sam.zoy.org/wtfpl/COPYING for more details.
11 */
12
13#ifdef HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include "php.h"
18#include "php_pipi.h"
19
20static function_entry pipi_functions[] = {
21        PHP_FE(pipi_get_color_from_string, NULL)   
22        PHP_FE(pipi_get_version, NULL)
23        PHP_FE(pipi_create_context, NULL)
24        PHP_FE(pipi_get_command_list, NULL)
25        PHP_FE(pipi_command, NULL)
26        PHP_FE(pipi_load, NULL)
27        PHP_FE(pipi_load_stock, NULL)
28        PHP_FE(pipi_new, NULL)
29        PHP_FE(pipi_copy, NULL)
30        PHP_FE(pipi_save, NULL)
31        PHP_FE(pipi_set_gamma, NULL)
32        PHP_FE(pipi_getpixels, NULL)
33        PHP_FE(pipi_get_image_width, NULL)
34        PHP_FE(pipi_get_image_height, NULL)
35        PHP_FE(pipi_get_image_pitch, NULL)
36        PHP_FE(pipi_get_image_last_modified, NULL)
37        PHP_FE(pipi_get_format_name, NULL)
38        PHP_FE(pipi_measure_msd, NULL)
39        PHP_FE(pipi_measure_rmsd, NULL)
40        PHP_FE(pipi_resize, NULL)
41        PHP_FE(pipi_render_random, NULL)
42        PHP_FE(pipi_render_bayer, NULL)
43        PHP_FE(pipi_render_halftone, NULL)
44        PHP_FE(pipi_rgb, NULL)
45        PHP_FE(pipi_red, NULL)
46        PHP_FE(pipi_green, NULL)
47        PHP_FE(pipi_blue, NULL)
48        PHP_FE(pipi_mean, NULL)
49        PHP_FE(pipi_min, NULL)
50        PHP_FE(pipi_max, NULL)
51        PHP_FE(pipi_add, NULL)
52        PHP_FE(pipi_sub, NULL)
53        PHP_FE(pipi_difference, NULL)
54        PHP_FE(pipi_multiply, NULL)
55        PHP_FE(pipi_divide, NULL)
56        PHP_FE(pipi_screen, NULL)
57        PHP_FE(pipi_overlay, NULL)
58        PHP_FE(pipi_convolution, NULL)
59        PHP_FE(pipi_gaussian_blur, NULL)
60        PHP_FE(pipi_gaussian_blur_ext, NULL)
61        PHP_FE(pipi_box_blur, NULL)
62        PHP_FE(pipi_box_blur_ext, NULL)
63        PHP_FE(pipi_brightness, NULL)
64        PHP_FE(pipi_contrast, NULL)
65        PHP_FE(pipi_autocontrast, NULL)
66        PHP_FE(pipi_invert, NULL)
67        PHP_FE(pipi_threshold, NULL)
68        PHP_FE(pipi_hflip, NULL)
69        PHP_FE(pipi_vflip, NULL)
70        PHP_FE(pipi_rotate90, NULL)
71        PHP_FE(pipi_rotate180, NULL)
72        PHP_FE(pipi_rotate270, NULL)
73        PHP_FE(pipi_median, NULL)
74        PHP_FE(pipi_median_ext, NULL)
75        PHP_FE(pipi_dilate, NULL)
76        PHP_FE(pipi_erode, NULL)
77        PHP_FE(pipi_order, NULL)
78        PHP_FE(pipi_tile, NULL)
79        PHP_FE(pipi_flood_fill, NULL)
80        PHP_FE(pipi_draw_line, NULL)
81        PHP_FE(pipi_draw_polyline, NULL)
82        PHP_FE(pipi_draw_bezier4, NULL)
83        PHP_FE(pipi_reduce, NULL)
84        PHP_FE(pipi_dither_ediff, NULL)
85        PHP_FE(pipi_dither_ordered, NULL)
86        PHP_FE(pipi_dither_ordered_ext, NULL)
87        PHP_FE(pipi_dither_halftone, NULL)
88        PHP_FE(pipi_dither_random, NULL)
89        PHP_FE(pipi_dither_ostromoukhov, NULL)
90        PHP_FE(pipi_dither_dbs, NULL)
91        PHP_FE(pipi_dither_24to16, NULL)
92        PHP_FE(pipi_new_histogram, NULL)
93        PHP_FE(pipi_get_image_histogram, NULL)
94        PHP_FE(pipi_render_histogram, NULL)
95
96        {NULL, NULL, NULL}
97};
98
99zend_module_entry pipi_module_entry = {
100#if ZEND_MODULE_API_NO >= 20010901
101        STANDARD_MODULE_HEADER,
102#endif
103        PHP_PIPI_EXTNAME,
104        pipi_functions,
105        PHP_MINIT(pipi),
106        NULL,
107        NULL,
108        NULL,
109        PHP_MINFO(pipi),
110#if ZEND_MODULE_API_NO >= 20010901
111        PHP_PIPI_VERSION,
112#endif
113        STANDARD_MODULE_PROPERTIES
114};
115
116#ifdef COMPILE_DL_PIPI
117ZEND_GET_MODULE(pipi)
118#endif
119
120PHP_MINFO_FUNCTION(pipi) {
121        php_info_print_table_start();
122        php_info_print_table_row(2, "Pipi library version", pipi_get_version());
123        php_info_print_table_end();
124}
125
126
127//--------PIPI'S RESSOURCES---------//
128
129static void php_pipi_image_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
130        pipi_free(rsrc->ptr);
131}
132
133static void php_pipi_context_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
134        pipi_destroy_context(rsrc->ptr);
135}
136
137static void php_pipi_histogram_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
138        pipi_free_histogram(rsrc->ptr);
139}
140
141PHP_MINIT_FUNCTION(pipi) {
142        le_pipi_image = zend_register_list_destructors_ex(php_pipi_image_dtor, NULL, PHP_PIPI_IMAGE_RES_NAME, module_number);
143        le_pipi_context = zend_register_list_destructors_ex(php_pipi_context_dtor, NULL, PHP_PIPI_CONTEXT_RES_NAME, module_number);
144        le_pipi_histogram = zend_register_list_destructors_ex(php_pipi_histogram_dtor, NULL, PHP_PIPI_HISTOGRAM_RES_NAME, module_number);
145        return SUCCESS;
146}
147
148//----------SOMEMACROS---------------//
149
150#define FETCH_STR(str) \
151        int __len; \
152        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &__len) == FAILURE) { \
153                RETURN_FALSE; \
154        }
155
156#define FETCH_LONG(l) \
157        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &l) == FAILURE) { \
158                RETURN_FALSE; \
159        }
160
161#define FETCH_IMG(img) \
162        zval *_zval; \
163        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &_zval) == FAILURE) { \
164                RETURN_FALSE; \
165        } \
166        ZEND_FETCH_RESOURCE(img, pipi_image_t*, &_zval, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
167
168#define FETCH_IMG_IMG(img1, img2) \
169        zval *_zval1; \
170        zval *_zval2; \
171        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &_zval1, &_zval2) == FAILURE) { \
172                RETURN_FALSE; \
173        } \
174        ZEND_FETCH_RESOURCE(img1, pipi_image_t*, &_zval1, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image); \
175        ZEND_FETCH_RESOURCE(img2, pipi_image_t*, &_zval2, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
176
177
178
179//--------PIPI'S FUNCTIONS---------//
180
181PHP_FUNCTION(pipi_get_color_from_string) {
182}
183
184PHP_FUNCTION(pipi_get_version) {
185        RETURN_STRING(estrdup(pipi_get_version()), 0);
186}
187
188PHP_FUNCTION(pipi_create_context) {
189        pipi_context_t *context;
190        context = pipi_create_context();
191        ZEND_REGISTER_RESOURCE(return_value, context, le_pipi_context);
192}
193
194PHP_FUNCTION(pipi_get_command_list) {
195}
196
197PHP_FUNCTION(pipi_command) {
198}
199
200PHP_FUNCTION(pipi_load) {
201        char *str;
202        FETCH_STR(str);
203        pipi_image_t *img;
204        img = pipi_load(str);
205        ZEND_REGISTER_RESOURCE(return_value, img, le_pipi_image);
206}
207
208PHP_FUNCTION(pipi_load_stock) {
209        char *str;
210        FETCH_STR(str);
211        pipi_image_t *img;
212        img = pipi_load_stock(str);
213        ZEND_REGISTER_RESOURCE(return_value, img, le_pipi_image);
214}
215
216PHP_FUNCTION(pipi_new) {
217        long width = 0;
218        long height = 0;
219        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &width, &height) == FAILURE) {
220                RETURN_FALSE;
221        }
222        pipi_image_t *img;
223        img = pipi_new(width, height);
224        ZEND_REGISTER_RESOURCE(return_value, img, le_pipi_image);
225}
226
227PHP_FUNCTION(pipi_copy) {
228        pipi_image_t *src;
229        FETCH_IMG(src);
230        pipi_image_t *result;
231        result = pipi_copy(src);
232        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
233}
234
235PHP_FUNCTION(pipi_save) {
236        zval *res;
237        char *str;
238        int str_len;
239        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &res, &str, &str_len) == FAILURE) {
240                RETURN_FALSE;
241        }
242
243        pipi_image_t *img;
244        ZEND_FETCH_RESOURCE(img, pipi_image_t*, &res, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
245
246        RETURN_LONG(pipi_save(img, str));       
247}
248
249PHP_FUNCTION(pipi_set_gamma) {
250        long value;
251        FETCH_LONG(value);
252        pipi_set_gamma(value);
253}
254
255PHP_FUNCTION(pipi_getpixels) {
256}
257
258PHP_FUNCTION(pipi_get_image_width) {
259        pipi_image_t *img;
260        FETCH_IMG(img);
261        RETURN_LONG(pipi_get_image_width(img));
262}
263
264PHP_FUNCTION(pipi_get_image_height) {
265        pipi_image_t *img;
266        FETCH_IMG(img);
267        RETURN_LONG(pipi_get_image_height(img));
268}
269
270PHP_FUNCTION(pipi_get_image_pitch) {
271        pipi_image_t *img;
272        FETCH_IMG(img);
273        RETURN_LONG(pipi_get_image_pitch(img));
274}
275
276PHP_FUNCTION(pipi_get_image_last_modified) {
277        pipi_image_t *img;
278        FETCH_IMG(img);
279        RETURN_LONG(pipi_get_image_last_midified(img));
280}
281
282PHP_FUNCTION(pipi_get_format_name) {
283        long id;
284        FETCH_LONG(id);
285        RETURN_STRING(estrdup(pipi_get_format_name(id)), 0);
286}
287
288PHP_FUNCTION(pipi_measure_msd) {
289        pipi_image_t *img1;
290        pipi_image_t *img2;
291        FETCH_IMG_IMG(img1, img2);
292        RETURN_LONG(pipi_measure_msd(img1, img2));
293}
294
295PHP_FUNCTION(pipi_measure_rmsd) {
296        pipi_image_t *img1;
297        pipi_image_t *img2;
298        FETCH_IMG_IMG(img1, img2);
299        RETURN_LONG(pipi_measure_rmsd(img1, img2));
300}
301
302PHP_FUNCTION(pipi_resize) {
303        zval *_zval;
304        long width = 0;
305        long height = 0;
306        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &_zval, &width, &height) == FAILURE) {
307                RETURN_FALSE;
308        }
309        pipi_image_t *src;
310        ZEND_FETCH_RESOURCE(src, pipi_image_t*, &_zval, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
311
312        pipi_image_t *result;
313        result = pipi_resize(src, width, height);
314        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
315}
316
317PHP_FUNCTION(pipi_render_random) {
318        long width = 0;
319        long height = 0;
320        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &width, &height) == FAILURE) {
321                RETURN_FALSE;
322        }
323        pipi_image_t *img;
324        img = pipi_render_random(width, height);
325        ZEND_REGISTER_RESOURCE(return_value, img, le_pipi_image);
326}
327
328PHP_FUNCTION(pipi_render_bayer) {
329        long width = 0;
330        long height = 0;
331        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &width, &height) == FAILURE) {
332                RETURN_FALSE;
333        }
334        pipi_image_t *img;
335        img = pipi_render_bayer(width, height);
336        ZEND_REGISTER_RESOURCE(return_value, img, le_pipi_image);
337}
338
339PHP_FUNCTION(pipi_render_halftone) {
340        long width = 0;
341        long height = 0;
342        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &width, &height) == FAILURE) {
343                RETURN_FALSE;
344        }
345        pipi_image_t *img;
346        img = pipi_render_halftone(width, height);
347        ZEND_REGISTER_RESOURCE(return_value, img, le_pipi_image);
348}
349
350PHP_FUNCTION(pipi_rgb) {
351        zval *_zval1;
352        zval *_zval2;
353        zval *_zval3;
354        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrr", &_zval1, &_zval2, &_zval3) == FAILURE) {
355                RETURN_FALSE;
356        }
357
358        pipi_image_t *img_r;
359        pipi_image_t *img_g;
360        pipi_image_t *img_b;
361
362        ZEND_FETCH_RESOURCE(img_r, pipi_image_t*, &_zval1, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
363        ZEND_FETCH_RESOURCE(img_g, pipi_image_t*, &_zval2, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
364        ZEND_FETCH_RESOURCE(img_b, pipi_image_t*, &_zval3, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
365
366        pipi_image_t *result;
367        result = pipi_rgb(img_r, img_g, img_b);
368        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
369}
370
371PHP_FUNCTION(pipi_red) {
372        pipi_image_t *src;
373        FETCH_IMG(src);
374        pipi_image_t *result;
375        result = pipi_red(src);
376        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
377}
378
379PHP_FUNCTION(pipi_green) {
380        pipi_image_t *src;
381        FETCH_IMG(src);
382        pipi_image_t *result;
383        result = pipi_green(src);
384        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
385}
386
387PHP_FUNCTION(pipi_blue) {
388        pipi_image_t *src;
389        FETCH_IMG(src);
390        pipi_image_t *result;
391        result = pipi_blue(src);
392        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
393}
394
395PHP_FUNCTION(pipi_mean) {
396        pipi_image_t *img1;
397        pipi_image_t *img2;
398        FETCH_IMG_IMG(img1, img2);
399        pipi_image_t *result;
400        result = pipi_mean(img1, img2);
401        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
402}
403
404PHP_FUNCTION(pipi_min) {
405        pipi_image_t *img1;
406        pipi_image_t *img2;
407        FETCH_IMG_IMG(img1, img2);
408        pipi_image_t *result;
409        result = pipi_min(img1, img2);
410        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
411}
412
413PHP_FUNCTION(pipi_max) {
414        pipi_image_t *img1;
415        pipi_image_t *img2;
416        FETCH_IMG_IMG(img1, img2);
417        pipi_image_t *result;
418        result = pipi_max(img1, img2);
419        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
420}
421
422PHP_FUNCTION(pipi_add) {
423        pipi_image_t *img1;
424        pipi_image_t *img2;
425        FETCH_IMG_IMG(img1, img2);
426        pipi_image_t *result;
427        result = pipi_add(img1, img2);
428        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
429}
430
431PHP_FUNCTION(pipi_sub) {
432        pipi_image_t *img1;
433        pipi_image_t *img2;
434        FETCH_IMG_IMG(img1, img2);
435        pipi_image_t *result;
436        result = pipi_sub(img1, img2);
437        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
438}
439
440PHP_FUNCTION(pipi_difference) {
441        pipi_image_t *img1;
442        pipi_image_t *img2;
443        FETCH_IMG_IMG(img1, img2);
444        pipi_image_t *result;
445        result = pipi_difference(img1, img2);
446        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
447}
448
449PHP_FUNCTION(pipi_multiply) {
450        pipi_image_t *img1;
451        pipi_image_t *img2;
452        FETCH_IMG_IMG(img1, img2);
453        pipi_image_t *result;
454        result = pipi_multiply(img1, img2);
455        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
456}
457
458PHP_FUNCTION(pipi_divide) {
459        pipi_image_t *img1;
460        pipi_image_t *img2;
461        FETCH_IMG_IMG(img1, img2);
462        pipi_image_t *result;
463        result = pipi_divide(img1, img2);
464        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
465}
466
467PHP_FUNCTION(pipi_screen) {
468        pipi_image_t *img1;
469        pipi_image_t *img2;
470        FETCH_IMG_IMG(img1, img2);
471        pipi_image_t *result;
472        result = pipi_screen(img1, img2);
473        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
474}
475
476PHP_FUNCTION(pipi_overlay) {
477        pipi_image_t *img1;
478        pipi_image_t *img2;
479        FETCH_IMG_IMG(img1, img2);
480        pipi_image_t *result;
481        result = pipi_overlay(img1, img2);
482        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
483}
484
485PHP_FUNCTION(pipi_convolution) {
486}
487
488PHP_FUNCTION(pipi_gaussian_blur) {
489}
490
491PHP_FUNCTION(pipi_gaussian_blur_ext) {
492}
493
494PHP_FUNCTION(pipi_box_blur) {
495}
496
497PHP_FUNCTION(pipi_box_blur_ext) {
498}
499
500PHP_FUNCTION(pipi_brightness) {
501        zval *_zval;
502        long value = 0;
503        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &_zval, &value) == FAILURE) {
504                RETURN_FALSE;
505        }
506        pipi_image_t *src;
507        ZEND_FETCH_RESOURCE(src, pipi_image_t*, &_zval, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
508
509        pipi_image_t *result;
510        result = pipi_brightness(src, value);
511        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
512}
513
514PHP_FUNCTION(pipi_contrast) {
515        zval *_zval;
516        long value = 0;
517        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &_zval, &value) == FAILURE) {
518                RETURN_FALSE;
519        }
520        pipi_image_t *src;
521        ZEND_FETCH_RESOURCE(src, pipi_image_t*, &_zval, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
522
523        pipi_image_t *result;
524        result = pipi_contrast(src, value);
525        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
526}
527
528PHP_FUNCTION(pipi_autocontrast) {
529        pipi_image_t *src;
530        FETCH_IMG(src);
531        pipi_image_t *result;
532        result = pipi_autocontrast(src);
533        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
534}
535
536PHP_FUNCTION(pipi_invert) {
537        pipi_image_t *src;
538        FETCH_IMG(src);
539        pipi_image_t *result;
540        result = pipi_invert(src);
541        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
542}
543
544PHP_FUNCTION(pipi_threshold) {
545}
546
547PHP_FUNCTION(pipi_hflip) {
548        pipi_image_t *src;
549        FETCH_IMG(src);
550        pipi_image_t *result;
551        result = pipi_hflip(src);
552        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
553}
554
555PHP_FUNCTION(pipi_vflip) {
556        pipi_image_t *src;
557        FETCH_IMG(src);
558        pipi_image_t *result;
559        result = pipi_vflip(src);
560        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
561}
562
563PHP_FUNCTION(pipi_rotate90) {
564        pipi_image_t *src;
565        FETCH_IMG(src);
566        pipi_image_t *result;
567        result = pipi_rotate90(src);
568        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
569}
570
571PHP_FUNCTION(pipi_rotate180) {
572        pipi_image_t *src;
573        FETCH_IMG(src);
574        pipi_image_t *result;
575        result = pipi_rotate180(src);
576        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
577}
578
579PHP_FUNCTION(pipi_rotate270) {
580        pipi_image_t *src;
581        FETCH_IMG(src);
582        pipi_image_t *result;
583        result = pipi_rotate270(src);
584        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
585}
586
587PHP_FUNCTION(pipi_median) {
588}
589
590PHP_FUNCTION(pipi_median_ext) {
591}
592
593PHP_FUNCTION(pipi_dilate) {
594        pipi_image_t *src;
595        FETCH_IMG(src);
596        pipi_image_t *result;
597        result = pipi_dilate(src);
598        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
599}
600
601PHP_FUNCTION(pipi_erode) {
602        pipi_image_t *src;
603        FETCH_IMG(src);
604        pipi_image_t *result;
605        result = pipi_erode(src);
606        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
607}
608
609PHP_FUNCTION(pipi_order) {
610        pipi_image_t *src;
611        FETCH_IMG(src);
612        pipi_image_t *result;
613        result = pipi_order(src);
614        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
615}
616
617PHP_FUNCTION(pipi_tile) {
618        zval *_zval;
619        long width = 0;
620        long height = 0;
621        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &_zval, &width, &height) == FAILURE) {
622                RETURN_FALSE;
623        }
624        pipi_image_t *src;
625        ZEND_FETCH_RESOURCE(src, pipi_image_t*, &_zval, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
626
627        pipi_image_t *result;
628        result = pipi_tile(src, width, height);
629        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
630}
631
632PHP_FUNCTION(pipi_flood_fill) {
633}
634
635PHP_FUNCTION(pipi_draw_line) {
636}
637
638PHP_FUNCTION(pipi_draw_polyline) {
639}
640
641PHP_FUNCTION(pipi_draw_bezier4) {
642}
643
644PHP_FUNCTION(pipi_reduce) {
645}
646
647PHP_FUNCTION(pipi_dither_ediff) {
648}
649
650PHP_FUNCTION(pipi_dither_ordered) {
651        pipi_image_t *img1;
652        pipi_image_t *img2;
653        FETCH_IMG_IMG(img1, img2);
654        pipi_image_t *result;
655        result = pipi_dither_ordered(img1, img2);
656        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
657}
658
659PHP_FUNCTION(pipi_dither_ordered_ext) {
660}
661
662PHP_FUNCTION(pipi_dither_halftone) {
663}
664
665PHP_FUNCTION(pipi_dither_random) {
666        pipi_image_t *src;
667        FETCH_IMG(src);
668        pipi_image_t *result;
669        result = pipi_dither_random(src);
670        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
671}
672
673PHP_FUNCTION(pipi_dither_ostromoukhov) {
674}
675
676PHP_FUNCTION(pipi_dither_dbs) {
677        pipi_image_t *src;
678        FETCH_IMG(src);
679        pipi_image_t *result;
680        result = pipi_dither_dbs(src);
681        ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
682}
683
684PHP_FUNCTION(pipi_dither_24to16) {
685        pipi_image_t *img;
686        FETCH_IMG(img);
687        pipi_dither_24to16(img);
688}
689
690PHP_FUNCTION(pipi_new_histogram) {
691        pipi_histogram_t *histogram;
692        histogram = pipi_new_histogram();
693        ZEND_REGISTER_RESOURCE(return_value, histogram, le_pipi_histogram);
694}
695
696PHP_FUNCTION(pipi_get_image_histogram) {
697}
698
699PHP_FUNCTION(pipi_render_histogram) {
700}
701
702
Note: See TracBrowser for help on using the repository browser.