ソースを参照

Initial release of pipi-php

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@3069 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
nico 16年前
コミット
df0f1550cb
4個のファイルの変更864行の追加0行の削除
  1. +13
    -0
      pipi-php/config.m4
  2. +37
    -0
      pipi-php/package.xml
  3. +702
    -0
      pipi-php/php_pipi.c
  4. +112
    -0
      pipi-php/php_pipi.h

+ 13
- 0
pipi-php/config.m4 ファイルの表示

@@ -0,0 +1,13 @@
PHP_ARG_ENABLE(pipi, whether to enable Libpipi support,
[ --enable-pipi Enable Libpipi support])

if test "$PHP_PIPI" = "yes"; then
PHP_NEW_EXTENSION(pipi, php_pipi.c, $ext_shared)
PHP_SUBST(PIPI_SHARED_LIBADD)
AC_DEFINE(HAVE_PIPI, 1, [Whether you have Libpipi Ext])
PIPI_INCDIR=$PHP_PIPI/include
PIPI_LIBDIR=$PHP_PIPI/lib
PHP_ADD_LIBRARY_WITH_PATH(pipi, $PIPI_LIBDIR, PIPI_SHARED_LIBADD)
PHP_ADD_INCLUDE($PIPI_INCDIR)
fi


+ 37
- 0
pipi-php/package.xml ファイルの表示

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0">
<package version="1.0" packagerversion="1.4.8">
<name>pipi</name>
<summary>PHP binding for libpipi</summary>
<description>This extension allows PHP scripts to use libpipi.
</description>
<maintainers>
<maintainer>
<user>zMoo</user>
<name>Nicolas Vion</name>
<email>nico@yojik.eu</email>
<role>lead</role>
</maintainer>
</maintainers>
<release>
<version>0.1</version>
<date>2008-10-15</date>
<license>GPL</license>
<state>alpha</state>
<notes>See included ChangeLog for details...
</notes>
<deps>
<dep type="php" rel="ge" version="4.0.0"/>
</deps>
<filelist>
<file role="data" name="examples/example1.php"/>
<file role="src" name="config.m4"/>
<file role="data" name="COPYING"/>
<file role="data" name="EXPERIMENTAL"/>
<file role="src" name="php_pipi.c"/>
<file role="src" name="php_pipi.h"/>
<file role="data" name="README"/>
<file role="data" name="ChangeLog"/>
</filelist>
</release>
</package>

+ 702
- 0
pipi-php/php_pipi.c ファイルの表示

@@ -0,0 +1,702 @@
/*
* php-pipi Php binding for Libpipi
* Copyright (c) 2008 Vion Nicolas <nico@picapo.net>
*
*
* This library is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"
#include "php_pipi.h"

static function_entry pipi_functions[] = {
PHP_FE(pipi_get_color_from_string, NULL)
PHP_FE(pipi_get_version, NULL)
PHP_FE(pipi_create_context, NULL)
PHP_FE(pipi_get_command_list, NULL)
PHP_FE(pipi_command, NULL)
PHP_FE(pipi_load, NULL)
PHP_FE(pipi_load_stock, NULL)
PHP_FE(pipi_new, NULL)
PHP_FE(pipi_copy, NULL)
PHP_FE(pipi_save, NULL)
PHP_FE(pipi_set_gamma, NULL)
PHP_FE(pipi_getpixels, NULL)
PHP_FE(pipi_get_image_width, NULL)
PHP_FE(pipi_get_image_height, NULL)
PHP_FE(pipi_get_image_pitch, NULL)
PHP_FE(pipi_get_image_last_modified, NULL)
PHP_FE(pipi_get_format_name, NULL)
PHP_FE(pipi_measure_msd, NULL)
PHP_FE(pipi_measure_rmsd, NULL)
PHP_FE(pipi_resize, NULL)
PHP_FE(pipi_render_random, NULL)
PHP_FE(pipi_render_bayer, NULL)
PHP_FE(pipi_render_halftone, NULL)
PHP_FE(pipi_rgb, NULL)
PHP_FE(pipi_red, NULL)
PHP_FE(pipi_green, NULL)
PHP_FE(pipi_blue, NULL)
PHP_FE(pipi_mean, NULL)
PHP_FE(pipi_min, NULL)
PHP_FE(pipi_max, NULL)
PHP_FE(pipi_add, NULL)
PHP_FE(pipi_sub, NULL)
PHP_FE(pipi_difference, NULL)
PHP_FE(pipi_multiply, NULL)
PHP_FE(pipi_divide, NULL)
PHP_FE(pipi_screen, NULL)
PHP_FE(pipi_overlay, NULL)
PHP_FE(pipi_convolution, NULL)
PHP_FE(pipi_gaussian_blur, NULL)
PHP_FE(pipi_gaussian_blur_ext, NULL)
PHP_FE(pipi_box_blur, NULL)
PHP_FE(pipi_box_blur_ext, NULL)
PHP_FE(pipi_brightness, NULL)
PHP_FE(pipi_contrast, NULL)
PHP_FE(pipi_autocontrast, NULL)
PHP_FE(pipi_invert, NULL)
PHP_FE(pipi_threshold, NULL)
PHP_FE(pipi_hflip, NULL)
PHP_FE(pipi_vflip, NULL)
PHP_FE(pipi_rotate90, NULL)
PHP_FE(pipi_rotate180, NULL)
PHP_FE(pipi_rotate270, NULL)
PHP_FE(pipi_median, NULL)
PHP_FE(pipi_median_ext, NULL)
PHP_FE(pipi_dilate, NULL)
PHP_FE(pipi_erode, NULL)
PHP_FE(pipi_order, NULL)
PHP_FE(pipi_tile, NULL)
PHP_FE(pipi_flood_fill, NULL)
PHP_FE(pipi_draw_line, NULL)
PHP_FE(pipi_draw_polyline, NULL)
PHP_FE(pipi_draw_bezier4, NULL)
PHP_FE(pipi_reduce, NULL)
PHP_FE(pipi_dither_ediff, NULL)
PHP_FE(pipi_dither_ordered, NULL)
PHP_FE(pipi_dither_ordered_ext, NULL)
PHP_FE(pipi_dither_halftone, NULL)
PHP_FE(pipi_dither_random, NULL)
PHP_FE(pipi_dither_ostromoukhov, NULL)
PHP_FE(pipi_dither_dbs, NULL)
PHP_FE(pipi_dither_24to16, NULL)
PHP_FE(pipi_new_histogram, NULL)
PHP_FE(pipi_get_image_histogram, NULL)
PHP_FE(pipi_render_histogram, NULL)

{NULL, NULL, NULL}
};

zend_module_entry pipi_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
PHP_PIPI_EXTNAME,
pipi_functions,
PHP_MINIT(pipi),
NULL,
NULL,
NULL,
PHP_MINFO(pipi),
#if ZEND_MODULE_API_NO >= 20010901
PHP_PIPI_VERSION,
#endif
STANDARD_MODULE_PROPERTIES
};

#ifdef COMPILE_DL_PIPI
ZEND_GET_MODULE(pipi)
#endif

PHP_MINFO_FUNCTION(pipi) {
php_info_print_table_start();
php_info_print_table_row(2, "Pipi library version", pipi_get_version());
php_info_print_table_end();
}


//--------PIPI'S RESSOURCES---------//

static void php_pipi_image_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
pipi_free(rsrc->ptr);
}

static void php_pipi_context_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
pipi_destroy_context(rsrc->ptr);
}

static void php_pipi_histogram_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
pipi_free_histogram(rsrc->ptr);
}

PHP_MINIT_FUNCTION(pipi) {
le_pipi_image = zend_register_list_destructors_ex(php_pipi_image_dtor, NULL, PHP_PIPI_IMAGE_RES_NAME, module_number);
le_pipi_context = zend_register_list_destructors_ex(php_pipi_context_dtor, NULL, PHP_PIPI_CONTEXT_RES_NAME, module_number);
le_pipi_histogram = zend_register_list_destructors_ex(php_pipi_histogram_dtor, NULL, PHP_PIPI_HISTOGRAM_RES_NAME, module_number);
return SUCCESS;
}

//----------SOMEMACROS---------------//

#define FETCH_STR(str) \
int __len; \
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &__len) == FAILURE) { \
RETURN_FALSE; \
}

#define FETCH_LONG(l) \
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &l) == FAILURE) { \
RETURN_FALSE; \
}

#define FETCH_IMG(img) \
zval *_zval; \
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &_zval) == FAILURE) { \
RETURN_FALSE; \
} \
ZEND_FETCH_RESOURCE(img, pipi_image_t*, &_zval, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);

#define FETCH_IMG_IMG(img1, img2) \
zval *_zval1; \
zval *_zval2; \
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &_zval1, &_zval2) == FAILURE) { \
RETURN_FALSE; \
} \
ZEND_FETCH_RESOURCE(img1, pipi_image_t*, &_zval1, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image); \
ZEND_FETCH_RESOURCE(img2, pipi_image_t*, &_zval2, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);



//--------PIPI'S FUNCTIONS---------//

PHP_FUNCTION(pipi_get_color_from_string) {
}

PHP_FUNCTION(pipi_get_version) {
RETURN_STRING(estrdup(pipi_get_version()), 0);
}

PHP_FUNCTION(pipi_create_context) {
pipi_context_t *context;
context = pipi_create_context();
ZEND_REGISTER_RESOURCE(return_value, context, le_pipi_context);
}

PHP_FUNCTION(pipi_get_command_list) {
}

PHP_FUNCTION(pipi_command) {
}

PHP_FUNCTION(pipi_load) {
char *str;
FETCH_STR(str);
pipi_image_t *img;
img = pipi_load(str);
ZEND_REGISTER_RESOURCE(return_value, img, le_pipi_image);
}

PHP_FUNCTION(pipi_load_stock) {
char *str;
FETCH_STR(str);
pipi_image_t *img;
img = pipi_load_stock(str);
ZEND_REGISTER_RESOURCE(return_value, img, le_pipi_image);
}

PHP_FUNCTION(pipi_new) {
long width = 0;
long height = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &width, &height) == FAILURE) {
RETURN_FALSE;
}
pipi_image_t *img;
img = pipi_new(width, height);
ZEND_REGISTER_RESOURCE(return_value, img, le_pipi_image);
}

PHP_FUNCTION(pipi_copy) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_copy(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_save) {
zval *res;
char *str;
int str_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &res, &str, &str_len) == FAILURE) {
RETURN_FALSE;
}

pipi_image_t *img;
ZEND_FETCH_RESOURCE(img, pipi_image_t*, &res, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);

RETURN_LONG(pipi_save(img, str));
}

PHP_FUNCTION(pipi_set_gamma) {
long value;
FETCH_LONG(value);
pipi_set_gamma(value);
}

PHP_FUNCTION(pipi_getpixels) {
}

PHP_FUNCTION(pipi_get_image_width) {
pipi_image_t *img;
FETCH_IMG(img);
RETURN_LONG(pipi_get_image_width(img));
}

PHP_FUNCTION(pipi_get_image_height) {
pipi_image_t *img;
FETCH_IMG(img);
RETURN_LONG(pipi_get_image_height(img));
}

PHP_FUNCTION(pipi_get_image_pitch) {
pipi_image_t *img;
FETCH_IMG(img);
RETURN_LONG(pipi_get_image_pitch(img));
}

PHP_FUNCTION(pipi_get_image_last_modified) {
pipi_image_t *img;
FETCH_IMG(img);
RETURN_LONG(pipi_get_image_last_midified(img));
}

PHP_FUNCTION(pipi_get_format_name) {
long id;
FETCH_LONG(id);
RETURN_STRING(estrdup(pipi_get_format_name(id)), 0);
}

PHP_FUNCTION(pipi_measure_msd) {
pipi_image_t *img1;
pipi_image_t *img2;
FETCH_IMG_IMG(img1, img2);
RETURN_LONG(pipi_measure_msd(img1, img2));
}

PHP_FUNCTION(pipi_measure_rmsd) {
pipi_image_t *img1;
pipi_image_t *img2;
FETCH_IMG_IMG(img1, img2);
RETURN_LONG(pipi_measure_rmsd(img1, img2));
}

PHP_FUNCTION(pipi_resize) {
zval *_zval;
long width = 0;
long height = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &_zval, &width, &height) == FAILURE) {
RETURN_FALSE;
}
pipi_image_t *src;
ZEND_FETCH_RESOURCE(src, pipi_image_t*, &_zval, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);

pipi_image_t *result;
result = pipi_resize(src, width, height);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_render_random) {
long width = 0;
long height = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &width, &height) == FAILURE) {
RETURN_FALSE;
}
pipi_image_t *img;
img = pipi_render_random(width, height);
ZEND_REGISTER_RESOURCE(return_value, img, le_pipi_image);
}

PHP_FUNCTION(pipi_render_bayer) {
long width = 0;
long height = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &width, &height) == FAILURE) {
RETURN_FALSE;
}
pipi_image_t *img;
img = pipi_render_bayer(width, height);
ZEND_REGISTER_RESOURCE(return_value, img, le_pipi_image);
}

PHP_FUNCTION(pipi_render_halftone) {
long width = 0;
long height = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &width, &height) == FAILURE) {
RETURN_FALSE;
}
pipi_image_t *img;
img = pipi_render_halftone(width, height);
ZEND_REGISTER_RESOURCE(return_value, img, le_pipi_image);
}

PHP_FUNCTION(pipi_rgb) {
zval *_zval1;
zval *_zval2;
zval *_zval3;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrr", &_zval1, &_zval2, &_zval3) == FAILURE) {
RETURN_FALSE;
}

pipi_image_t *img_r;
pipi_image_t *img_g;
pipi_image_t *img_b;

ZEND_FETCH_RESOURCE(img_r, pipi_image_t*, &_zval1, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
ZEND_FETCH_RESOURCE(img_g, pipi_image_t*, &_zval2, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
ZEND_FETCH_RESOURCE(img_b, pipi_image_t*, &_zval3, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);

pipi_image_t *result;
result = pipi_rgb(img_r, img_g, img_b);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_red) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_red(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_green) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_green(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_blue) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_blue(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_mean) {
pipi_image_t *img1;
pipi_image_t *img2;
FETCH_IMG_IMG(img1, img2);
pipi_image_t *result;
result = pipi_mean(img1, img2);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_min) {
pipi_image_t *img1;
pipi_image_t *img2;
FETCH_IMG_IMG(img1, img2);
pipi_image_t *result;
result = pipi_min(img1, img2);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_max) {
pipi_image_t *img1;
pipi_image_t *img2;
FETCH_IMG_IMG(img1, img2);
pipi_image_t *result;
result = pipi_max(img1, img2);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_add) {
pipi_image_t *img1;
pipi_image_t *img2;
FETCH_IMG_IMG(img1, img2);
pipi_image_t *result;
result = pipi_add(img1, img2);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_sub) {
pipi_image_t *img1;
pipi_image_t *img2;
FETCH_IMG_IMG(img1, img2);
pipi_image_t *result;
result = pipi_sub(img1, img2);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_difference) {
pipi_image_t *img1;
pipi_image_t *img2;
FETCH_IMG_IMG(img1, img2);
pipi_image_t *result;
result = pipi_difference(img1, img2);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_multiply) {
pipi_image_t *img1;
pipi_image_t *img2;
FETCH_IMG_IMG(img1, img2);
pipi_image_t *result;
result = pipi_multiply(img1, img2);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_divide) {
pipi_image_t *img1;
pipi_image_t *img2;
FETCH_IMG_IMG(img1, img2);
pipi_image_t *result;
result = pipi_divide(img1, img2);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_screen) {
pipi_image_t *img1;
pipi_image_t *img2;
FETCH_IMG_IMG(img1, img2);
pipi_image_t *result;
result = pipi_screen(img1, img2);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_overlay) {
pipi_image_t *img1;
pipi_image_t *img2;
FETCH_IMG_IMG(img1, img2);
pipi_image_t *result;
result = pipi_overlay(img1, img2);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_convolution) {
}

PHP_FUNCTION(pipi_gaussian_blur) {
}

PHP_FUNCTION(pipi_gaussian_blur_ext) {
}

PHP_FUNCTION(pipi_box_blur) {
}

PHP_FUNCTION(pipi_box_blur_ext) {
}

PHP_FUNCTION(pipi_brightness) {
zval *_zval;
long value = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &_zval, &value) == FAILURE) {
RETURN_FALSE;
}
pipi_image_t *src;
ZEND_FETCH_RESOURCE(src, pipi_image_t*, &_zval, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);

pipi_image_t *result;
result = pipi_brightness(src, value);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_contrast) {
zval *_zval;
long value = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &_zval, &value) == FAILURE) {
RETURN_FALSE;
}
pipi_image_t *src;
ZEND_FETCH_RESOURCE(src, pipi_image_t*, &_zval, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);

pipi_image_t *result;
result = pipi_contrast(src, value);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_autocontrast) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_autocontrast(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_invert) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_invert(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_threshold) {
}

PHP_FUNCTION(pipi_hflip) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_hflip(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_vflip) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_vflip(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_rotate90) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_rotate90(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_rotate180) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_rotate180(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_rotate270) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_rotate270(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_median) {
}

PHP_FUNCTION(pipi_median_ext) {
}

PHP_FUNCTION(pipi_dilate) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_dilate(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_erode) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_erode(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_order) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_order(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_tile) {
zval *_zval;
long width = 0;
long height = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &_zval, &width, &height) == FAILURE) {
RETURN_FALSE;
}
pipi_image_t *src;
ZEND_FETCH_RESOURCE(src, pipi_image_t*, &_zval, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);

pipi_image_t *result;
result = pipi_tile(src, width, height);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_flood_fill) {
}

PHP_FUNCTION(pipi_draw_line) {
}

PHP_FUNCTION(pipi_draw_polyline) {
}

PHP_FUNCTION(pipi_draw_bezier4) {
}

PHP_FUNCTION(pipi_reduce) {
}

PHP_FUNCTION(pipi_dither_ediff) {
}

PHP_FUNCTION(pipi_dither_ordered) {
pipi_image_t *img1;
pipi_image_t *img2;
FETCH_IMG_IMG(img1, img2);
pipi_image_t *result;
result = pipi_dither_ordered(img1, img2);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_dither_ordered_ext) {
}

PHP_FUNCTION(pipi_dither_halftone) {
}

PHP_FUNCTION(pipi_dither_random) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_dither_random(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_dither_ostromoukhov) {
}

PHP_FUNCTION(pipi_dither_dbs) {
pipi_image_t *src;
FETCH_IMG(src);
pipi_image_t *result;
result = pipi_dither_dbs(src);
ZEND_REGISTER_RESOURCE(return_value, result, le_pipi_image);
}

PHP_FUNCTION(pipi_dither_24to16) {
pipi_image_t *img;
FETCH_IMG(img);
pipi_dither_24to16(img);
}

PHP_FUNCTION(pipi_new_histogram) {
pipi_histogram_t *histogram;
histogram = pipi_new_histogram();
ZEND_REGISTER_RESOURCE(return_value, histogram, le_pipi_histogram);
}

PHP_FUNCTION(pipi_get_image_histogram) {
}

PHP_FUNCTION(pipi_render_histogram) {
}



+ 112
- 0
pipi-php/php_pipi.h ファイルの表示

@@ -0,0 +1,112 @@
/*
* php-pipi Php binding for Libpipi
* Copyright (c) 2008 Vion Nicolas <nico@picapo.net>
*
*
* This library is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

#ifndef PHP_PIPI_H
#define PHP_PIPI_H

#include <pipi.h>


#define PHP_PIPI_VERSION "0.0"
#define PHP_PIPI_EXTNAME "pipi"

#define PHP_PIPI_IMAGE_RES_NAME "pipi_image"
#define PHP_PIPI_CONTEXT_RES_NAME "pipi_context"
#define PHP_PIPI_HISTOGRAM_RES_NAME "pipi_histogram"

int le_pipi_image;
int le_pipi_context;
int le_pipi_histogram;

PHP_MINIT_FUNCTION(pipi);
PHP_MINFO_FUNCTION(pipi);

PHP_FUNCTION(pipi_get_color_from_string);
PHP_FUNCTION(pipi_get_version);
PHP_FUNCTION(pipi_create_context);
PHP_FUNCTION(pipi_get_command_list);
PHP_FUNCTION(pipi_command);
PHP_FUNCTION(pipi_load);
PHP_FUNCTION(pipi_load_stock);
PHP_FUNCTION(pipi_new);
PHP_FUNCTION(pipi_copy);
PHP_FUNCTION(pipi_save);
PHP_FUNCTION(pipi_set_gamma);
PHP_FUNCTION(pipi_getpixels);
PHP_FUNCTION(pipi_get_image_width);
PHP_FUNCTION(pipi_get_image_height);
PHP_FUNCTION(pipi_get_image_pitch);
PHP_FUNCTION(pipi_get_image_last_modified);
PHP_FUNCTION(pipi_get_format_name);
PHP_FUNCTION(pipi_measure_msd);
PHP_FUNCTION(pipi_measure_rmsd);
PHP_FUNCTION(pipi_resize);
PHP_FUNCTION(pipi_render_random);
PHP_FUNCTION(pipi_render_bayer);
PHP_FUNCTION(pipi_render_halftone);
PHP_FUNCTION(pipi_rgb);
PHP_FUNCTION(pipi_red);
PHP_FUNCTION(pipi_green);
PHP_FUNCTION(pipi_blue);
PHP_FUNCTION(pipi_mean);
PHP_FUNCTION(pipi_min);
PHP_FUNCTION(pipi_max);
PHP_FUNCTION(pipi_add);
PHP_FUNCTION(pipi_sub);
PHP_FUNCTION(pipi_difference);
PHP_FUNCTION(pipi_multiply);
PHP_FUNCTION(pipi_divide);
PHP_FUNCTION(pipi_screen);
PHP_FUNCTION(pipi_overlay);
PHP_FUNCTION(pipi_convolution);
PHP_FUNCTION(pipi_gaussian_blur);
PHP_FUNCTION(pipi_gaussian_blur_ext);
PHP_FUNCTION(pipi_box_blur);
PHP_FUNCTION(pipi_box_blur_ext);
PHP_FUNCTION(pipi_brightness);
PHP_FUNCTION(pipi_contrast);
PHP_FUNCTION(pipi_autocontrast);
PHP_FUNCTION(pipi_invert);
PHP_FUNCTION(pipi_threshold);
PHP_FUNCTION(pipi_hflip);
PHP_FUNCTION(pipi_vflip);
PHP_FUNCTION(pipi_rotate90);
PHP_FUNCTION(pipi_rotate180);
PHP_FUNCTION(pipi_rotate270);
PHP_FUNCTION(pipi_median);
PHP_FUNCTION(pipi_median_ext);
PHP_FUNCTION(pipi_dilate);
PHP_FUNCTION(pipi_erode);
PHP_FUNCTION(pipi_order);
PHP_FUNCTION(pipi_tile);
PHP_FUNCTION(pipi_flood_fill);
PHP_FUNCTION(pipi_draw_line);
PHP_FUNCTION(pipi_draw_polyline);
PHP_FUNCTION(pipi_draw_bezier4);
PHP_FUNCTION(pipi_reduce);
PHP_FUNCTION(pipi_dither_ediff);
PHP_FUNCTION(pipi_dither_ordered);
PHP_FUNCTION(pipi_dither_ordered_ext);
PHP_FUNCTION(pipi_dither_halftone);
PHP_FUNCTION(pipi_dither_random);
PHP_FUNCTION(pipi_dither_ostromoukhov);
PHP_FUNCTION(pipi_dither_dbs);
PHP_FUNCTION(pipi_dither_24to16);
PHP_FUNCTION(pipi_new_histogram);
PHP_FUNCTION(pipi_get_image_histogram);
PHP_FUNCTION(pipi_render_histogram);

extern zend_module_entry pipi_module_entry;
#define phpext_pipi_ptr &pipi_module_entry


#endif

読み込み中…
キャンセル
保存