@@ -918,6 +918,12 @@ 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 )
922
+ ZEND_ARG_INFO (0 , im )
923
+ ZEND_ARG_INFO (0 , matrox )
924
+ ZEND_ARG_INFO (0 , options )
925
+ ZEND_END_ARG_INFO ()
926
+
921
927
ZEND_BEGIN_ARG_INFO (arginfo_imagesetinterpolation , 0 )
922
928
ZEND_ARG_INFO (0 , im )
923
929
ZEND_ARG_INFO (0 , method )
@@ -988,6 +994,7 @@ const zend_function_entry gd_functions[] = {
988
994
PHP_FE (imagecropauto , arginfo_imagecropauto )
989
995
PHP_FE (imagescale , arginfo_imagescale )
990
996
PHP_FE (imageaffine , arginfo_imageaffine )
997
+ PHP_FE (imageaffinegetmatrix , arginfo_imageaffinegetmatrix )
991
998
PHP_FE (imagesetinterpolation , arginfo_imagesetinterpolation )
992
999
#endif
993
1000
@@ -5394,6 +5401,7 @@ PHP_FUNCTION(imageaffine)
5394
5401
double affine [6 ];
5395
5402
int i , nelems ;
5396
5403
zval * * zval_affine_elem = NULL ;
5404
+
5397
5405
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "ra|a" , & IM , & z_affine , & z_rect ) == FAILURE ) {
5398
5406
return ;
5399
5407
}
@@ -5427,27 +5435,31 @@ PHP_FUNCTION(imageaffine)
5427
5435
5428
5436
if (z_rect != NULL ) {
5429
5437
if (zend_hash_find (HASH_OF (z_rect ), "x" , sizeof ("x" ), (void * * )& tmp ) != FAILURE ) {
5438
+ convert_to_long_ex (tmp );
5430
5439
rect .x = Z_LVAL_PP (tmp );
5431
5440
} else {
5432
5441
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Missing x position ");
5433
5442
RETURN_FALSE ;
5434
5443
}
5435
5444
5436
5445
if (zend_hash_find (HASH_OF (z_rect ), "y" , sizeof ("x" ), (void * * )& tmp ) != FAILURE ) {
5446
+ convert_to_long_ex (tmp );
5437
5447
rect .y = Z_LVAL_PP (tmp );
5438
5448
} else {
5439
5449
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Missing y position ");
5440
5450
RETURN_FALSE ;
5441
5451
}
5442
5452
5443
5453
if (zend_hash_find (HASH_OF (z_rect ), "width" , sizeof ("width" ), (void * * )& tmp ) != FAILURE ) {
5454
+ convert_to_long_ex (tmp );
5444
5455
rect .width = Z_LVAL_PP (tmp );
5445
5456
} else {
5446
5457
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Missing width ");
5447
5458
RETURN_FALSE ;
5448
5459
}
5449
5460
5450
5461
if (zend_hash_find (HASH_OF (z_rect ), "height" , sizeof ("height" ), (void * * )& tmp ) != FAILURE ) {
5462
+ convert_to_long_ex (tmp );
5451
5463
rect .height = Z_LVAL_PP (tmp );
5452
5464
} else {
5453
5465
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Missing height ");
@@ -5476,6 +5488,77 @@ PHP_FUNCTION(imageaffine)
5476
5488
}
5477
5489
/* }}} */
5478
5490
5491
+ /* {{{ proto array imageaffinegetmatrix(type[, options])
5492
+ Return an image containing the affine tramsformed src image, using an optional clipping area */
5493
+ PHP_FUNCTION (imageaffinegetmatrix )
5494
+ {
5495
+ double affine [6 ];
5496
+ gdAffineStandardMatrix type ;
5497
+ zval * options ;
5498
+ zval * * tmp ;
5499
+ int args_required ;
5500
+ int res ;
5501
+
5502
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "l|z" , & type , & options ) == FAILURE ) {
5503
+ return ;
5504
+ }
5505
+
5506
+ switch (type ) {
5507
+ case GD_AFFINE_TRANSLATE :
5508
+ case GD_AFFINE_SCALE : {
5509
+ double x , y ;
5510
+ args_required = 2 ;
5511
+ if (Z_TYPE_P (options ) != IS_ARRAY ) {
5512
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Array expected as options" );
5513
+ }
5514
+ if (zend_hash_find (HASH_OF (options ), "x" , sizeof ("x" ), (void * * )& tmp ) != FAILURE ) {
5515
+ convert_to_double_ex (tmp );
5516
+ x = Z_DVAL_PP (tmp );
5517
+ } else {
5518
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Missing x position ");
5519
+ RETURN_FALSE ;
5520
+ }
5521
+
5522
+ if (zend_hash_find (HASH_OF (options ), "y" , sizeof ("y" ), (void * * )& tmp ) != FAILURE ) {
5523
+ convert_to_double_ex (tmp );
5524
+ y = Z_DVAL_PP (tmp );
5525
+ } else {
5526
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Missing y position ");
5527
+ RETURN_FALSE ;
5528
+ }
5529
+
5530
+ if (type == GD_AFFINE_TRANSLATE ) {
5531
+ res = gdAffineTranslate (affine , x , y );
5532
+ } else {
5533
+ res = gdAffineScale (affine , x , y );
5534
+ }
5535
+ break ;
5536
+ }
5537
+
5538
+ case GD_AFFINE_ROTATE :
5539
+ case GD_AFFINE_SHEAR_HORIZONTAL :
5540
+ case GD_AFFINE_SHEAR_VERTICAL : {
5541
+ double angle ;
5542
+
5543
+ convert_to_double_ex (& options );
5544
+ angle = Z_DVAL_P (options );
5545
+
5546
+ if (type == GD_AFFINE_SHEAR_HORIZONTAL ) {
5547
+ res = gdAffineShearHorizontal (affine , angle );
5548
+ } else if (type == GD_AFFINE_SHEAR_VERTICAL ) {
5549
+ res = gdAffineShearVertical (affine , angle );
5550
+ } else {
5551
+ res = gdAffineRotate (affine , angle );
5552
+ }
5553
+ break ;
5554
+ }
5555
+
5556
+ default :
5557
+ php_error_docref (NULL TSRMLS_CC , E_WARNING , "Invalid type for element %i" , type );
5558
+ RETURN_FALSE ;
5559
+ }
5560
+ }
5561
+
5479
5562
/* {{{ proto resource imagesetinterpolation(resource im, [, method]])
5480
5563
Set the default interpolation method, passing -1 or 0 sets it to the libgd default (bilinear). */
5481
5564
PHP_FUNCTION (imagesetinterpolation )
0 commit comments