@@ -135,7 +135,6 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
135
135
static void _php_image_output (INTERNAL_FUNCTION_PARAMETERS , int image_type , char * tn , void (* func_p )());
136
136
static int _php_image_type (char data [12 ]);
137
137
static void _php_image_convert (INTERNAL_FUNCTION_PARAMETERS , int image_type );
138
- static void _php_image_bw_convert (gdImagePtr im_org , gdIOCtx * out , int threshold );
139
138
140
139
/* {{{ arginfo */
141
140
ZEND_BEGIN_ARG_INFO (arginfo_gd_info , 0 )
@@ -764,7 +763,7 @@ ZEND_END_ARG_INFO()
764
763
ZEND_BEGIN_ARG_INFO_EX (arginfo_image2wbmp , 0 , 0 , 1 )
765
764
ZEND_ARG_INFO (0 , im )
766
765
ZEND_ARG_INFO (0 , filename )
767
- ZEND_ARG_INFO (0 , threshold )
766
+ ZEND_ARG_INFO (0 , foreground )
768
767
ZEND_END_ARG_INFO ()
769
768
770
769
#if defined(HAVE_GD_JPG )
@@ -1000,7 +999,7 @@ static const zend_function_entry gd_functions[] = {
1000
999
#if defined(HAVE_GD_PNG )
1001
1000
PHP_DEP_FE (png2wbmp , arginfo_png2wbmp )
1002
1001
#endif
1003
- PHP_FE (image2wbmp , arginfo_image2wbmp )
1002
+ PHP_DEP_FE (image2wbmp , arginfo_image2wbmp )
1004
1003
PHP_FE (imagelayereffect , arginfo_imagelayereffect )
1005
1004
PHP_FE (imagexbm , arginfo_imagexbm )
1006
1005
@@ -2600,7 +2599,7 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
2600
2599
int argc = ZEND_NUM_ARGS ();
2601
2600
int q = -1 , i , t = 1 ;
2602
2601
2603
- /* The quality parameter for Wbmp stands for the threshold when called from image2wbmp() */
2602
+ /* The quality parameter for Wbmp stands for the foreground when called from image2wbmp() */
2604
2603
/* When called from imagewbmp() the quality parameter stands for the foreground color. Default: black. */
2605
2604
/* The quality parameter for gd2 stands for chunk size */
2606
2605
@@ -4073,11 +4072,11 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
4073
4072
/* }}} */
4074
4073
#endif /* ENABLE_GD_TTF */
4075
4074
4076
- /* {{{ proto bool image2wbmp(resource im [, string filename [, int threshold ]])
4075
+ /* {{{ proto bool image2wbmp(resource im [, string filename [, int foreground ]])
4077
4076
Output WBMP image to browser or file */
4078
4077
PHP_FUNCTION (image2wbmp )
4079
4078
{
4080
- _php_image_output (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_CONVERT_WBM , "WBMP" , _php_image_bw_convert );
4079
+ _php_image_output (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_CONVERT_WBM , "WBMP" , NULL );
4081
4080
}
4082
4081
/* }}} */
4083
4082
@@ -4101,59 +4100,6 @@ PHP_FUNCTION(png2wbmp)
4101
4100
/* }}} */
4102
4101
#endif
4103
4102
4104
- /* {{{ _php_image_bw_convert
4105
- * It converts a gd Image to bw using a threshold value */
4106
- static void _php_image_bw_convert (gdImagePtr im_org , gdIOCtx * out , int threshold )
4107
- {
4108
- gdImagePtr im_dest ;
4109
- int white , black ;
4110
- int color , color_org , median ;
4111
- int dest_height = gdImageSY (im_org );
4112
- int dest_width = gdImageSX (im_org );
4113
- int x , y ;
4114
-
4115
- im_dest = gdImageCreate (dest_width , dest_height );
4116
- if (im_dest == NULL ) {
4117
- php_error_docref (NULL , E_WARNING , "Unable to allocate temporary buffer" );
4118
- return ;
4119
- }
4120
-
4121
- white = gdImageColorAllocate (im_dest , 255 , 255 , 255 );
4122
- if (white == -1 ) {
4123
- php_error_docref (NULL , E_WARNING , "Unable to allocate the colors for the destination buffer" );
4124
- return ;
4125
- }
4126
-
4127
- black = gdImageColorAllocate (im_dest , 0 , 0 , 0 );
4128
- if (black == -1 ) {
4129
- php_error_docref (NULL , E_WARNING , "Unable to allocate the colors for the destination buffer" );
4130
- return ;
4131
- }
4132
-
4133
- if (im_org -> trueColor ) {
4134
- if (!gdImageTrueColorToPalette (im_org , 1 , 256 )) {
4135
- php_error_docref (NULL , E_WARNING , "Unable to convert to palette" );
4136
- return ;
4137
- }
4138
- }
4139
-
4140
- for (y = 0 ; y < dest_height ; y ++ ) {
4141
- for (x = 0 ; x < dest_width ; x ++ ) {
4142
- color_org = gdImageGetPixel (im_org , x , y );
4143
- median = (im_org -> red [color_org ] + im_org -> green [color_org ] + im_org -> blue [color_org ]) / 3 ;
4144
- if (median < threshold ) {
4145
- color = black ;
4146
- } else {
4147
- color = white ;
4148
- }
4149
- gdImageSetPixel (im_dest , x , y , color );
4150
- }
4151
- }
4152
- gdImageWBMPCtx (im_dest , black , out );
4153
-
4154
- }
4155
- /* }}} */
4156
-
4157
4103
/* {{{ _php_image_convert
4158
4104
* _php_image_convert converts jpeg/png images to wbmp and resizes them as needed */
4159
4105
static void _php_image_convert (INTERNAL_FUNCTION_PARAMETERS , int image_type )
0 commit comments