cvs: php4 /ext/gd gd.c php_gd.h

From: Date: Sun, 25 Jun 2000 02:55:31 +0000
Subject: cvs: php4 /ext/gd gd.c php_gd.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-440@lists.php.net to get a copy of this message
sterling Sat Jun 24 19:55:31 2000 EDT Modified files: /php4/ext/gd gd.c php_gd.h Log: @- Added the ImageCopyMerge, ImagePaletteCopy and ImageColorClosestHWB functions. (Sterling) -Added the ImageCopyMerge, ImagePaletteCopy and ImageColorClosestHWB functions Index: php4/ext/gd/gd.c diff -u php4/ext/gd/gd.c:1.72 php4/ext/gd/gd.c:1.73 --- php4/ext/gd/gd.c:1.72 Sat Jun 24 18:44:15 2000 +++ php4/ext/gd/gd.c Sat Jun 24 19:55:31 2000 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: gd.c,v 1.72 2000/06/25 01:44:15 jah Exp $ */ +/* $Id: gd.c,v 1.73 2000/06/25 02:55:31 sterling Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -99,8 +99,10 @@ PHP_FE(imagechar, NULL) PHP_FE(imagecharup, NULL) PHP_FE(imagecolorallocate, NULL) + PHP_FE(imagepalettecopy, NULL) PHP_FE(imagecolorat, NULL) PHP_FE(imagecolorclosest, NULL) + PHP_FE(imagecolorclosesthwb, NULL) PHP_FE(imagecolordeallocate, NULL) PHP_FE(imagecolorresolve, NULL) PHP_FE(imagecolorexact, NULL) @@ -109,6 +111,7 @@ PHP_FE(imagecolorstotal, NULL) PHP_FE(imagecolorsforindex, NULL) PHP_FE(imagecopy, NULL) + PHP_FE(imagecopymerge, NULL) PHP_FE(imagecopyresized, NULL) PHP_FE(imagecreate, NULL) PHP_FE(imagecreatefrompng, NULL) @@ -759,6 +762,25 @@ } /* }}} */ +/* {{{ proto int imagepalettecopy(int dst, int src) + Copy the palette from the src image onto the dst image */ +PHP_FUNCTION(imagepalettecopy) +{ + zval **dstim, **srcim; + gdImagePtr dst, src; + + if (ZEND_NUM_ARGS() != 2 || + zend_get_parameters_ex(2, &dstim, &srcim) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(dst, gdImagePtr, dstim, -1, "Image", GDG(le_gd)); + ZEND_FETCH_RESOURCE(src, gdImagePtr, srcim, -1, "Image", GDG(le_gd)); + + gdImagePaletteCopy(dst, src); +} +/* }}} */ + /* im, x, y */ /* {{{ proto int imagecolorat(int im, int x, int y) Get the index of the color of a pixel */ @@ -819,6 +841,31 @@ } /* }}} */ +/* {{{ proto int imagecolorclosesthwb(int im, int red, int green, int blue) + Get the index of the color which has the hue, white and blackness nearest to the given color */ +PHP_FUNCTION(imagecolorclosesthwb) +{ + zval **imgind, **r, **g, **b; + int col; + gdImagePtr im; + GDLS_FETCH(); + + if (ZEND_NUM_ARGS() != 4 || + zend_get_parameters_ex(4, &imgind, &r, &g, &b) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", GDG(le_gd)); + + convert_to_long_ex(r); + convert_to_long_ex(g); + convert_to_long_ex(b); + + col = gdImageColorClosestHWB(im, Z_LVAL_PP(r), Z_LVAL_PP(g), Z_LVAL_PP(b)); + RETURN_LONG(col); +} +/* }}} */ + /* {{{ proto int imagecolordeallocate(int im, int index) De-allocate a color for an image */ PHP_FUNCTION(imagecolordeallocate) @@ -1705,6 +1752,43 @@ RETURN_TRUE; } /* }}} */ + + +PHP_FUNCTION(imagecopymerge) +{ + zval **SIM, **DIM, **SX, **SY, **SW, **SH, **DX, **DY, **PCT; + gdImagePtr im_dst; + gdImagePtr im_src; + int srcH, srcW, srcY, srcX, dstY, dstX, pct; + GDLS_FETCH(); + + if (ZEND_NUM_ARGS() != 9 || + zend_get_parameters_ex(9, &DIM, &SIM, &DX, &DY, &SX, &SY, &SW, &SH, &PCT) == FAILURE) { + WRONG_PARAM_COUNT; + } + + ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", GDG(le_gd)); + ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, DIM, -1, "Image", GDG(le_gd)); + + convert_to_long_ex(SX); + convert_to_long_ex(SY); + convert_to_long_ex(SW); + convert_to_long_ex(SH); + convert_to_long_ex(DX); + convert_to_long_ex(DY); + convert_to_long_ex(PCT); + + srcX = Z_LVAL_PP(SX); + srcY = Z_LVAL_PP(SY); + srcH = Z_LVAL_PP(SH); + srcW = Z_LVAL_PP(SW); + dstX = Z_LVAL_PP(DX) + dstY = Z_LVAL_PP(DY); + pct = Z_LVAL_PP(PCT); + + gdImageCopyMerge(im_dst, im_src, dstX, dstY, srcX, srcY, srcW, srcH, pct); + RETURN_TRUE; +} /* {{{ proto int imagecopyresized(int dst_im, int src_im, int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h) Copy and resize part of an image */ Index: php4/ext/gd/php_gd.h diff -u php4/ext/gd/php_gd.h:1.12 php4/ext/gd/php_gd.h:1.13 --- php4/ext/gd/php_gd.h:1.12 Sat Jun 24 18:44:15 2000 +++ php4/ext/gd/php_gd.h Sat Jun 24 19:55:31 2000 @@ -29,7 +29,7 @@ */ -/* $Id: php_gd.h,v 1.12 2000/06/25 01:44:15 jah Exp $ */ +/* $Id: php_gd.h,v 1.13 2000/06/25 02:55:31 sterling Exp $ */ #ifndef _PHP_GD_H #define _PHP_GD_H @@ -80,8 +80,10 @@ PHP_FUNCTION(imagechar); PHP_FUNCTION(imagecharup); PHP_FUNCTION(imagecolorallocate); +PHP_FUNCTION(imagepalettecopy); PHP_FUNCTION(imagecolorat); PHP_FUNCTION(imagecolorclosest); +PHP_FUNCTION(imagecolorclosesthwb); PHP_FUNCTION(imagecolordeallocate); PHP_FUNCTION(imagecolorresolve); PHP_FUNCTION(imagecolorexact); @@ -90,6 +92,7 @@ PHP_FUNCTION(imagecolorsforindex); PHP_FUNCTION(imagecolortransparent); PHP_FUNCTION(imagecopy); +PHP_FUNCTION(imagecopymerge); PHP_FUNCTION(imagecopyresized); PHP_FUNCTION(imagecreate); PHP_FUNCTION(imagecreatefromgif);

« previous php.cvs (#440) next »