@@ -387,8 +387,11 @@ impl GifIO {
387
387
388
388
Header :: from_stream ( stream) ?;
389
389
let logical_screen_descriptor = LogicalScreenDescriptor :: from_stream ( stream) ?;
390
- if logical_screen_descriptor. color_table_flag {
391
- GlobalColorTable :: from_stream ( stream, logical_screen_descriptor. color_resolution ) ?;
390
+ if logical_screen_descriptor. global_color_table_flag {
391
+ GlobalColorTable :: from_stream (
392
+ stream,
393
+ logical_screen_descriptor. global_color_table_size ,
394
+ ) ?;
392
395
}
393
396
394
397
Ok ( ( ) )
@@ -716,10 +719,10 @@ impl Block {
716
719
LogicalScreenDescriptor :: from_stream ( stream) ?,
717
720
) ) ,
718
721
Block :: LogicalScreenDescriptor ( logical_screen_descriptor) => {
719
- match logical_screen_descriptor. color_table_flag {
722
+ match logical_screen_descriptor. global_color_table_flag {
720
723
true => Some ( Block :: GlobalColorTable ( GlobalColorTable :: from_stream (
721
724
stream,
722
- logical_screen_descriptor. color_resolution ,
725
+ logical_screen_descriptor. global_color_table_size ,
723
726
) ?) ) ,
724
727
false => None ,
725
728
}
@@ -828,23 +831,23 @@ impl Header {
828
831
829
832
#[ derive( Debug , Clone , PartialEq ) ]
830
833
struct LogicalScreenDescriptor {
831
- color_table_flag : bool ,
832
- color_resolution : u8 ,
834
+ global_color_table_flag : bool ,
835
+ global_color_table_size : u8 ,
833
836
}
834
837
835
838
impl LogicalScreenDescriptor {
836
839
fn from_stream ( stream : & mut dyn CAIRead ) -> Result < LogicalScreenDescriptor > {
837
840
stream. seek ( SeekFrom :: Current ( 4 ) ) ?;
838
841
839
842
let packed = stream. read_u8 ( ) ?;
840
- let color_table_flag = ( packed >> 7 ) & 1 ;
841
- let color_resolution = ( packed >> 4 ) & 0b111 ;
843
+ let global_color_table_flag = ( packed >> 7 ) & 1 ;
844
+ let global_color_table_size = packed & 0b111 ;
842
845
843
846
stream. seek ( SeekFrom :: Current ( 2 ) ) ?;
844
847
845
848
Ok ( LogicalScreenDescriptor {
846
- color_table_flag : color_table_flag != 0 ,
847
- color_resolution ,
849
+ global_color_table_flag : global_color_table_flag != 0 ,
850
+ global_color_table_size ,
848
851
} )
849
852
}
850
853
}
@@ -853,10 +856,8 @@ impl LogicalScreenDescriptor {
853
856
struct GlobalColorTable { }
854
857
855
858
impl GlobalColorTable {
856
- fn from_stream ( stream : & mut dyn CAIRead , color_resolution : u8 ) -> Result < GlobalColorTable > {
857
- stream. seek ( SeekFrom :: Current (
858
- 3 * ( 2_i64 . pow ( color_resolution as u32 + 1 ) ) ,
859
- ) ) ?;
859
+ fn from_stream ( stream : & mut dyn CAIRead , size : u8 ) -> Result < GlobalColorTable > {
860
+ stream. seek ( SeekFrom :: Current ( 3 * ( 2_i64 . pow ( size as u32 + 1 ) ) ) ) ?;
860
861
861
862
Ok ( GlobalColorTable { } )
862
863
}
@@ -1168,8 +1169,8 @@ mod tests {
1168
1169
start: 6 ,
1169
1170
len: 7 ,
1170
1171
block: Block :: LogicalScreenDescriptor ( LogicalScreenDescriptor {
1171
- color_table_flag : true ,
1172
- color_resolution : 7
1172
+ global_color_table_flag : true ,
1173
+ global_color_table_size : 7
1173
1174
} )
1174
1175
} )
1175
1176
) ;
0 commit comments