@@ -447,7 +447,7 @@ public static PhpResource imagecreatetruecolor(int x_size, int y_size)
447447 return img ;
448448 }
449449
450- static PhpGdImageResource imagecreatecommon ( int x_size , int y_size , IConfigurationModule configuration , IImageFormat format )
450+ static PhpGdImageResource imagecreatecommon ( int x_size , int y_size , IImageFormatConfigurationModule configuration , IImageFormat format )
451451 {
452452 if ( x_size <= 0 || y_size <= 0 )
453453 {
@@ -472,7 +472,9 @@ public static PhpResource imagecreatefromstring(byte[] image)
472472
473473 try
474474 {
475- return new PhpGdImageResource ( Image . Load < Rgba32 > ( image , out var format ) , format ) ;
475+ return new PhpGdImageResource (
476+ Image . Load < Rgba32 > ( image . AsSpan ( ) )
477+ ) ;
476478 }
477479 catch
478480 {
@@ -562,35 +564,35 @@ public static PhpResource imagecreatefromxpm(Context ctx, string filename)
562564 return imagercreatefromfile ( ctx , filename ) ;
563565 }
564566
565- static PhpGdImageResource imagercreatefromfile ( Context ctx , string filename , IConfigurationModule formatOpt = null )
567+ static PhpGdImageResource imagercreatefromfile ( Context ctx , string filename , IImageFormatConfigurationModule formatOpt = null )
566568 {
567569 if ( string . IsNullOrEmpty ( filename ) )
568570 {
569571 PhpException . Throw ( PhpError . Warning , Resources . filename_cannot_be_empty ) ;
570572 return null ;
571573 }
572574
573- var configuration = ( formatOpt == null )
574- ? Configuration . Default
575- : new Configuration ( formatOpt ) ;
575+ var decoderOptions = ( formatOpt == null )
576+ ? new DecoderOptions ( )
577+ : new DecoderOptions ( ) { Configuration = new Configuration ( formatOpt ) }
578+ ;
576579
577580 Image < Rgba32 > img = null ;
578- IImageFormat format = null ;
579-
581+
580582 using ( var stream = Utils . OpenStream ( ctx , filename ) )
581583 {
582584 if ( stream != null )
583585 {
584586 try
585587 {
586- img = Image . Load < Rgba32 > ( configuration , stream , out format ) ;
588+ img = Image . Load < Rgba32 > ( decoderOptions , stream ) ;
587589 }
588590 catch { }
589591 }
590592 }
591593
592594 return ( img != null )
593- ? new PhpGdImageResource ( img , format )
595+ ? new PhpGdImageResource ( img )
594596 : null ;
595597 }
596598
@@ -1264,7 +1266,13 @@ static bool imagecopy(PhpResource dst_im, PhpResource src_im, int dst_x, int dst
12641266 . Crop ( new Rectangle ( src_x , src_y , src_w , src_h ) )
12651267 . Resize ( new Size ( src_w , src_h ) ) ) )
12661268 {
1267- dst . Image . Mutate ( o => o . DrawImage ( cropped , opacity : opacity , location : new Point ( dst_x , dst_y ) ) ) ;
1269+ dst . Image . Mutate < Rgba32 > (
1270+ o => o . DrawImage (
1271+ cropped ,
1272+ opacity : opacity ,
1273+ backgroundLocation : new Point ( dst_x , dst_y )
1274+ )
1275+ ) ;
12681276 }
12691277 }
12701278 catch ( Exception ex )
@@ -1320,7 +1328,7 @@ public static bool imagegd(PhpResource im)
13201328 return imagesave ( ctx , im , to , ( img , stream ) =>
13211329 {
13221330 // use the source's encoder:
1323- var encoder = img . GetConfiguration ( ) . ImageFormatsManager . FindEncoder ( GifFormat . Instance ) as GifEncoder ;
1331+ var encoder = img . Configuration . ImageFormatsManager . GetEncoder ( GifFormat . Instance ) as GifEncoder ;
13241332
13251333 // or use default encoding options
13261334 encoder ??= new GifEncoder ( ) ; // TODO: ColorTableMode from allocated colors count?
0 commit comments