@@ -70,10 +70,10 @@ private void WritePixels<TPixel>(Image<TPixel> image, Stream stream)
7070 for ( int i = 0 ; i < pixels . Height ; i ++ )
7171 {
7272 Span < TPixel > row = pixels . DangerousGetRowSpan ( i ) ;
73- for ( int j = 0 ; j < pixels . Width && i < pixels . Height ; j ++ )
73+ for ( int j = 0 ; j < row . Length && i < pixels . Height ; j ++ )
7474 {
7575 // We get the RGBA value from pixels
76- TPixel currentPixel = pixels [ j , i ] ;
76+ TPixel currentPixel = row [ j ] ;
7777 currentPixel . ToRgba32 ( ref currentRgba32 ) ;
7878
7979 // First, we check if the current pixel is equal to the previous one
@@ -93,7 +93,7 @@ private void WritePixels<TPixel>(Image<TPixel> image, Stream stream)
9393 {
9494 repetitions ++ ;
9595 j ++ ;
96- if ( j == pixels . Width )
96+ if ( j == row . Length )
9797 {
9898 j = 0 ;
9999 i ++ ;
@@ -137,9 +137,9 @@ private void WritePixels<TPixel>(Image<TPixel> image, Stream stream)
137137 diffBlue = ( sbyte ) ( currentRgba32 . B - previousPixel . B ) ;
138138
139139 // If so, we do a QOI_OP_DIFF
140- if ( diffRed is > - 3 and < 2 &&
141- diffGreen is > - 3 and < 2 &&
142- diffBlue is > - 3 and < 2 &&
140+ if ( diffRed is >= - 2 and <= 1 &&
141+ diffGreen is >= - 2 and <= 1 &&
142+ diffBlue is >= - 2 and <= 1 &&
143143 currentRgba32 . A == previousPixel . A )
144144 {
145145 // Bottom limit is -2, so we add 2 to make it equal to 0
@@ -155,9 +155,9 @@ diffBlue is > -3 and < 2 &&
155155 // If so, we do a QOI_OP_LUMA
156156 sbyte diffRedGreen = ( sbyte ) ( diffRed - diffGreen ) ,
157157 diffBlueGreen = ( sbyte ) ( diffBlue - diffGreen ) ;
158- if ( diffGreen is > - 33 and < 8 &&
159- diffRedGreen is > - 9 and < 8 &&
160- diffBlueGreen is > - 9 and < 8 &&
158+ if ( diffGreen is >= - 32 and <= 31 &&
159+ diffRedGreen is >= - 8 and <= 7 &&
160+ diffBlueGreen is >= - 8 and <= 7 &&
161161 currentRgba32 . A == previousPixel . A )
162162 {
163163 byte dr_dg = ( byte ) ( diffRedGreen + 8 ) ,
0 commit comments