2727using System ;
2828using System . Collections ;
2929using System . Drawing ;
30- using System . Drawing . Imaging ;
3130using System . IO ;
3231
3332namespace Aga . Controls
@@ -88,14 +87,14 @@ public class GifDecoder
8887 private Image lastImage ; // previous frame
8988
9089 private byte [ ] block = new byte [ 256 ] ; // current data block
91- private int blockSize = 0 ; // block size
90+ private int blockSize ; // block size
9291
9392 // last graphic control extension info
94- private int dispose = 0 ;
93+ private int dispose ;
9594 // 0=no action; 1=leave in place; 2=restore to bg; 3=restore to prev
96- private int lastDispose = 0 ;
97- private bool transparency = false ; // use transparent color
98- private int delay = 0 ; // delay in milliseconds
95+ private int lastDispose ;
96+ private bool transparency ; // use transparent color
97+ private int delay ; // delay in milliseconds
9998 private int transIndex ; // transparent color index
10099
101100 private const int MaxStackSize = 4096 ;
@@ -286,15 +285,15 @@ private void SetPixels()
286285 int k = line * width ;
287286 int dx = k + ix ; // start of line in dest
288287 int dlim = dx + iw ; // end of dest line
289- if ( ( k + width ) < dlim )
288+ if ( k + width < dlim )
290289 {
291290 dlim = k + width ; // past dest edge
292291 }
293292 int sx = i * iw ; // start of line in source
294293 while ( dx < dlim )
295294 {
296295 // map color and insert in destination
297- int index = ( ( int ) pixels [ sx ++ ] ) & 0xff ;
296+ int index = ( int ) pixels [ sx ++ ] & 0xff ;
298297 int c = act [ index ] ;
299298 if ( c != 0 )
300299 {
@@ -312,13 +311,12 @@ private void SetPixels()
312311 *
313312 * @return BufferedImage representation of frame.
314313 */
315- public GifFrame GetFrame ( int n )
316- {
317- if ( ( n >= 0 ) && ( n < frameCount ) )
314+ public GifFrame GetFrame ( int n )
315+ {
316+ if ( n >= 0 && n < frameCount )
318317 return ( GifFrame ) frames [ n ] ;
319- else
320- throw new ArgumentOutOfRangeException ( ) ;
321- }
318+ throw new ArgumentOutOfRangeException ( ) ;
319+ }
322320
323321 /**
324322 * Gets image size.
@@ -390,7 +388,7 @@ private void DecodeImageData()
390388 bi ,
391389 pi ;
392390
393- if ( ( pixels == null ) || ( pixels . Length < npix ) )
391+ if ( pixels == null || pixels . Length < npix )
394392 {
395393 pixels = new byte [ npix ] ; // allocate new pixel array
396394 }
@@ -432,7 +430,7 @@ private void DecodeImageData()
432430 break ;
433431 bi = 0 ;
434432 }
435- datum += ( ( ( int ) block [ bi ] ) & 0xff ) << bits ;
433+ datum += ( ( int ) block [ bi ] & 0xff ) << bits ;
436434 bits += 8 ;
437435 bi ++ ;
438436 count -- ;
@@ -447,7 +445,7 @@ private void DecodeImageData()
447445
448446 // Interpret the code
449447
450- if ( ( code > available ) || ( code == end_of_information ) )
448+ if ( code > available || code == end_of_information )
451449 break ;
452450 if ( code == clear )
453451 {
@@ -476,7 +474,7 @@ private void DecodeImageData()
476474 pixelStack [ top ++ ] = suffix [ code ] ;
477475 code = prefix [ code ] ;
478476 }
479- first = ( ( int ) suffix [ code ] ) & 0xff ;
477+ first = ( int ) suffix [ code ] & 0xff ;
480478
481479 // Add a new string to the string table,
482480
@@ -486,8 +484,8 @@ private void DecodeImageData()
486484 prefix [ available ] = ( short ) old_code ;
487485 suffix [ available ] = ( byte ) first ;
488486 available ++ ;
489- if ( ( ( available & code_mask ) == 0 )
490- && ( available < MaxStackSize ) )
487+ if ( ( available & code_mask ) == 0
488+ && available < MaxStackSize )
491489 {
492490 code_size ++ ;
493491 code_mask += available ;
@@ -610,9 +608,9 @@ private int[] ReadColorTable(int ncolors)
610608 int j = 0 ;
611609 while ( i < ncolors )
612610 {
613- int r = ( ( int ) c [ j ++ ] ) & 0xff ;
614- int g = ( ( int ) c [ j ++ ] ) & 0xff ;
615- int b = ( ( int ) c [ j ++ ] ) & 0xff ;
611+ int r = ( int ) c [ j ++ ] & 0xff ;
612+ int g = ( int ) c [ j ++ ] & 0xff ;
613+ int b = ( int ) c [ j ++ ] & 0xff ;
616614 tab [ i ++ ] = ( int ) ( 0xff000000 | ( r << 16 ) | ( g << 8 ) | b ) ;
617615 }
618616 }
@@ -820,11 +818,11 @@ private void ReadNetscapeExt()
820818 if ( block [ 0 ] == 1 )
821819 {
822820 // loop count sub-block
823- int b1 = ( ( int ) block [ 1 ] ) & 0xff ;
824- int b2 = ( ( int ) block [ 2 ] ) & 0xff ;
821+ int b1 = ( int ) block [ 1 ] & 0xff ;
822+ int b2 = ( int ) block [ 2 ] & 0xff ;
825823 loopCount = ( b2 << 8 ) | b1 ;
826824 }
827- } while ( ( blockSize > 0 ) && ! Error ( ) ) ;
825+ } while ( blockSize > 0 && ! Error ( ) ) ;
828826 }
829827
830828 /**
@@ -858,7 +856,7 @@ private void Skip()
858856 do
859857 {
860858 ReadBlock ( ) ;
861- } while ( ( blockSize > 0 ) && ! Error ( ) ) ;
859+ } while ( blockSize > 0 && ! Error ( ) ) ;
862860 }
863861 }
864862}
0 commit comments