@@ -918,12 +918,17 @@ ZEND_BEGIN_ARG_INFO(arginfo_imageaffine, 0)
918
918
ZEND_ARG_INFO (0 , affine )
919
919
ZEND_END_ARG_INFO ()
920
920
921
- ZEND_BEGIN_ARG_INFO (arginfo_imageaffinegetmatrix , 0 )
921
+ ZEND_BEGIN_ARG_INFO (arginfo_imageaffinematrixget , 0 )
922
922
ZEND_ARG_INFO (0 , im )
923
923
ZEND_ARG_INFO (0 , matrox )
924
924
ZEND_ARG_INFO (0 , options )
925
925
ZEND_END_ARG_INFO ()
926
926
927
+ ZEND_BEGIN_ARG_INFO (arginfo_imageaffinematrixconcat , 0 )
928
+ ZEND_ARG_INFO (0 , m1 )
929
+ ZEND_ARG_INFO (0 , m2 )
930
+ ZEND_END_ARG_INFO ()
931
+
927
932
ZEND_BEGIN_ARG_INFO (arginfo_imagesetinterpolation , 0 )
928
933
ZEND_ARG_INFO (0 , im )
929
934
ZEND_ARG_INFO (0 , method )
@@ -994,7 +999,8 @@ const zend_function_entry gd_functions[] = {
994
999
PHP_FE (imagecropauto , arginfo_imagecropauto )
995
1000
PHP_FE (imagescale , arginfo_imagescale )
996
1001
PHP_FE (imageaffine , arginfo_imageaffine )
997
- PHP_FE (imageaffinegetmatrix , arginfo_imageaffinegetmatrix )
1002
+ PHP_FE (imageaffinematrixconcat , arginfo_imageaffinematrixconcat )
1003
+ PHP_FE (imageaffinematrixget , arginfo_imageaffinematrixget )
998
1004
PHP_FE (imagesetinterpolation , arginfo_imagesetinterpolation )
999
1005
#endif
1000
1006
@@ -1280,7 +1286,13 @@ PHP_MINIT_FUNCTION(gd)
1280
1286
REGISTER_LONG_CONSTANT ("IMG_NEAREST_NEIGHBOUR" , GD_NEAREST_NEIGHBOUR , CONST_CS | CONST_PERSISTENT );
1281
1287
REGISTER_LONG_CONSTANT ("IMG_WEIGHTED4" , GD_WEIGHTED4 , CONST_CS | CONST_PERSISTENT );
1282
1288
REGISTER_LONG_CONSTANT ("IMG_TRIANGLE" , GD_TRIANGLE , CONST_CS | CONST_PERSISTENT );
1283
- REGISTER_LONG_CONSTANT ("IMG_DEFAULT" , GD_BICUBIC_FIXED , CONST_CS | CONST_PERSISTENT );
1289
+
1290
+ REGISTER_LONG_CONSTANT ("IMG_AFFINE_TRANSLATE" , GD_AFFINE_TRANSLATE , CONST_CS | CONST_PERSISTENT );
1291
+ REGISTER_LONG_CONSTANT ("IMG_AFFINE_SCALE" , GD_AFFINE_SCALE , CONST_CS | CONST_PERSISTENT );
1292
+ REGISTER_LONG_CONSTANT ("IMG_AFFINE_ROTATE" , GD_AFFINE_ROTATE , CONST_CS | CONST_PERSISTENT );
1293
+ REGISTER_LONG_CONSTANT ("IMG_AFFINE_SHEAR_HORIZONTAL" , GD_AFFINE_SHEAR_HORIZONTAL , CONST_CS | CONST_PERSISTENT );
1294
+ REGISTER_LONG_CONSTANT ("IMG_AFFINE_SHEAR_VERTICAL" , GD_AFFINE_SHEAR_VERTICAL , CONST_CS | CONST_PERSISTENT );
1295
+
1284
1296
#else
1285
1297
REGISTER_LONG_CONSTANT ("GD_BUNDLED" , 0 , CONST_CS | CONST_PERSISTENT );
1286
1298
#endif
@@ -5488,26 +5500,24 @@ PHP_FUNCTION(imageaffine)
5488
5500
}
5489
5501
/* }}} */
5490
5502
5491
- /* {{{ proto array imageaffinegetmatrix (type[, options])
5503
+ /* {{{ proto array imageaffinematrixget (type[, options])
5492
5504
Return an image containing the affine tramsformed src image, using an optional clipping area */
5493
- PHP_FUNCTION (imageaffinegetmatrix )
5505
+ PHP_FUNCTION (imageaffinematrixget )
5494
5506
{
5495
5507
double affine [6 ];
5496
5508
gdAffineStandardMatrix type ;
5497
5509
zval * options ;
5498
5510
zval * * tmp ;
5499
- int args_required ;
5500
- int res ;
5511
+ int res , i ;
5501
5512
5502
5513
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "l|z" , & type , & options ) == FAILURE ) {
5503
5514
return ;
5504
5515
}
5505
-
5516
+
5506
5517
switch (type ) {
5507
5518
case GD_AFFINE_TRANSLATE :
5508
5519
case GD_AFFINE_SCALE : {
5509
5520
double x , y ;
5510
- args_required = 2 ;
5511
5521
if (Z_TYPE_P (options ) != IS_ARRAY ) {
5512
5522
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Array expected as options" );
5513
5523
}
@@ -5557,6 +5567,81 @@ PHP_FUNCTION(imageaffinegetmatrix)
5557
5567
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Invalid type for element %i" , type );
5558
5568
RETURN_FALSE ;
5559
5569
}
5570
+
5571
+ array_init (return_value );
5572
+ for (i = 0 ; i < 6 ; i ++ ) {
5573
+ add_index_double (return_value , i , affine [i ]);
5574
+ }
5575
+ }
5576
+
5577
+
5578
+ /* {{{ proto array imageaffineconcat(array m1, array m2)
5579
+ Concat two matrices (as in doing many ops in one go) */
5580
+ PHP_FUNCTION (imageaffinematrixconcat )
5581
+ {
5582
+ double m1 [6 ];
5583
+ double m2 [6 ];
5584
+ double mr [6 ];
5585
+
5586
+ zval * * tmp ;
5587
+ zval * z_m1 ;
5588
+ zval * z_m2 ;
5589
+ int i , nelems ;
5590
+
5591
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "aa" , & z_m1 , & z_m2 ) == FAILURE ) {
5592
+ return ;
5593
+ }
5594
+
5595
+ if (((nelems = zend_hash_num_elements (Z_ARRVAL_P (z_m1 ))) != 6 ) || (nelems = zend_hash_num_elements (Z_ARRVAL_P (z_m2 ))) != 6 ) {
5596
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Affine arrays must have six elements" );
5597
+ RETURN_FALSE ;
5598
+ }
5599
+
5600
+ for (i = 0 ; i < 6 ; i ++ ) {
5601
+ if (zend_hash_index_find (Z_ARRVAL_P (z_m1 ), i , (void * * ) & tmp ) == SUCCESS ) {
5602
+ switch (Z_TYPE_PP (tmp )) {
5603
+ case IS_LONG :
5604
+ m1 [i ] = Z_LVAL_PP (tmp );
5605
+ break ;
5606
+ case IS_DOUBLE :
5607
+ m1 [i ] = Z_DVAL_PP (tmp );
5608
+ break ;
5609
+ case IS_STRING :
5610
+ convert_to_double_ex (tmp );
5611
+ m1 [i ] = Z_DVAL_PP (tmp );
5612
+ break ;
5613
+ default :
5614
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Invalid type for element %i" , i );
5615
+ RETURN_FALSE ;
5616
+ }
5617
+ }
5618
+ if (zend_hash_index_find (Z_ARRVAL_P (z_m2 ), i , (void * * ) & tmp ) == SUCCESS ) {
5619
+ switch (Z_TYPE_PP (tmp )) {
5620
+ case IS_LONG :
5621
+ m2 [i ] = Z_LVAL_PP (tmp );
5622
+ break ;
5623
+ case IS_DOUBLE :
5624
+ m2 [i ] = Z_DVAL_PP (tmp );
5625
+ break ;
5626
+ case IS_STRING :
5627
+ convert_to_double_ex (tmp );
5628
+ m2 [i ] = Z_DVAL_PP (tmp );
5629
+ break ;
5630
+ default :
5631
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Invalid type for element %i" , i );
5632
+ RETURN_FALSE ;
5633
+ }
5634
+ }
5635
+ }
5636
+
5637
+ if (gdAffineConcat (mr , m1 , m2 ) != GD_TRUE ) {
5638
+ RETURN_FALSE ;
5639
+ }
5640
+
5641
+ array_init (return_value );
5642
+ for (i = 0 ; i < 6 ; i ++ ) {
5643
+ add_index_double (return_value , i , mr [i ]);
5644
+ }
5560
5645
}
5561
5646
5562
5647
/* {{{ proto resource imagesetinterpolation(resource im, [, method]])
0 commit comments