@@ -52,18 +52,20 @@ public static int stbi__gif_header(stbi__context s, stbi__gif g, int* comp, int
5252
5353 public static int stbi__gif_info_raw ( stbi__context s , int * x , int * y , int * comp )
5454 {
55- var g = new stbi__gif ( ) ;
56- if ( stbi__gif_header ( s , g , comp , 1 ) == 0 )
57- {
58- stbi__rewind ( s ) ;
59- return 0 ;
55+ using ( var g = new stbi__gif ( ) )
56+ {
57+ if ( stbi__gif_header ( s , g , comp , 1 ) == 0 )
58+ {
59+ stbi__rewind ( s ) ;
60+ return 0 ;
61+ }
62+
63+ if ( x != null )
64+ * x = g . w ;
65+ if ( y != null )
66+ * y = g . h ;
6067 }
6168
62- if ( x != null )
63- * x = g . w ;
64- if ( y != null )
65- * y = g . h ;
66-
6769 return 1 ;
6870 }
6971
@@ -362,61 +364,6 @@ public static void stbi__out_gif_code(stbi__gif g, ushort code)
362364 }
363365 }
364366
365- public static void * stbi__load_gif_main ( stbi__context s , int * * delays , int * x , int * y , int * z , int * comp ,
366- int req_comp )
367- {
368- if ( stbi__gif_test ( s ) != 0 )
369- {
370- var layers = 0 ;
371- byte * u = null ;
372- byte * _out_ = null ;
373- byte * two_back = null ;
374- var g = new stbi__gif ( ) ;
375- var stride = 0 ;
376- if ( delays != null )
377- * delays = null ;
378- do
379- {
380- u = stbi__gif_load_next ( s , g , comp , req_comp , two_back ) ;
381- if ( u != null )
382- {
383- * x = g . w ;
384- * y = g . h ;
385- ++ layers ;
386- stride = g . w * g . h * 4 ;
387- if ( _out_ != null )
388- {
389- _out_ = ( byte * ) CRuntime . realloc ( _out_ , ( ulong ) ( layers * stride ) ) ;
390- if ( delays != null )
391- * delays = ( int * ) CRuntime . realloc ( * delays , ( ulong ) ( sizeof ( int ) * layers ) ) ;
392- }
393- else
394- {
395- _out_ = ( byte * ) stbi__malloc ( ( ulong ) ( layers * stride ) ) ;
396- if ( delays != null )
397- * delays = ( int * ) stbi__malloc ( ( ulong ) ( layers * sizeof ( int ) ) ) ;
398- }
399-
400- CRuntime . memcpy ( _out_ + ( layers - 1 ) * stride , u , ( ulong ) stride ) ;
401- if ( layers >= 2 )
402- two_back = _out_ - 2 * stride ;
403- if ( delays != null )
404- ( * delays ) [ layers - 1U ] = g . delay ;
405- }
406- } while ( u != null ) ;
407-
408- CRuntime . free ( g . _out_ ) ;
409- CRuntime . free ( g . history ) ;
410- CRuntime . free ( g . background ) ;
411- if ( req_comp != 0 && req_comp != 4 )
412- _out_ = stbi__convert_format ( _out_ , 4 , req_comp , ( uint ) ( layers * g . w ) , ( uint ) g . h ) ;
413- * z = layers ;
414- return _out_ ;
415- }
416-
417- return ( byte * ) ( ulong ) ( stbi__err ( "not GIF" ) != 0 ? ( byte * ) null : null ) ;
418- }
419-
420367 public static void * stbi__gif_load ( stbi__context s , int * x , int * y , int * comp , int req_comp ,
421368 stbi__result_info * ri )
422369 {
0 commit comments