@@ -710,10 +710,10 @@ private void SetFrameMetadata(ImageFrameMetadata metadata)
710
710
gifMeta . ColorTableMode = GifColorTableMode . Local ;
711
711
712
712
Color [ ] colorTable = new Color [ this . imageDescriptor . LocalColorTableSize ] ;
713
- ref Rgb24 localBase = ref MemoryMarshal . GetReference ( MemoryMarshal . Cast < byte , Rgb24 > ( this . currentLocalColorTable ! . GetSpan ( ) [ ..this . currentLocalColorTableSize ] ) ) ;
713
+ ReadOnlySpan < Rgb24 > rgbTable = MemoryMarshal . Cast < byte , Rgb24 > ( this . currentLocalColorTable ! . GetSpan ( ) [ ..this . currentLocalColorTableSize ] ) ;
714
714
for ( int i = 0 ; i < colorTable . Length ; i ++ )
715
715
{
716
- colorTable [ i ] = new Color ( Unsafe . Add ( ref localBase , ( uint ) i ) ) ;
716
+ colorTable [ i ] = new Color ( rgbTable [ i ] ) ;
717
717
}
718
718
719
719
gifMeta . LocalColorTable = colorTable ;
@@ -784,13 +784,14 @@ private void ReadLogicalScreenDescriptorAndGlobalColorTable(BufferedReadStream s
784
784
this . globalColorTable = this . memoryAllocator . Allocate < byte > ( globalColorTableLength , AllocationOptions . Clean ) ;
785
785
786
786
// Read the global color table data from the stream and preserve it in the gif metadata
787
- stream . Read ( this . globalColorTable . GetSpan ( ) ) ;
787
+ Span < byte > globalColorTableSpan = this . globalColorTable . GetSpan ( ) ;
788
+ stream . Read ( globalColorTableSpan ) ;
788
789
789
790
Color [ ] colorTable = new Color [ this . logicalScreenDescriptor . GlobalColorTableSize ] ;
790
- ref Rgb24 globalBase = ref MemoryMarshal . GetReference ( MemoryMarshal . Cast < byte , Rgb24 > ( this . globalColorTable . GetSpan ( ) ) ) ;
791
+ ReadOnlySpan < Rgb24 > rgbTable = MemoryMarshal . Cast < byte , Rgb24 > ( globalColorTableSpan ) ;
791
792
for ( int i = 0 ; i < colorTable . Length ; i ++ )
792
793
{
793
- colorTable [ i ] = new Color ( Unsafe . Add ( ref globalBase , ( uint ) i ) ) ;
794
+ colorTable [ i ] = new Color ( rgbTable [ i ] ) ;
794
795
}
795
796
796
797
this . gifMetadata . GlobalColorTable = colorTable ;
0 commit comments