@@ -70,10 +70,10 @@ private void WritePixels<TPixel>(Image<TPixel> image, Stream stream)
70
70
for ( int i = 0 ; i < pixels . Height ; i ++ )
71
71
{
72
72
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 ++ )
74
74
{
75
75
// We get the RGBA value from pixels
76
- TPixel currentPixel = pixels [ j , i ] ;
76
+ TPixel currentPixel = row [ j ] ;
77
77
currentPixel . ToRgba32 ( ref currentRgba32 ) ;
78
78
79
79
// 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)
93
93
{
94
94
repetitions ++ ;
95
95
j ++ ;
96
- if ( j == pixels . Width )
96
+ if ( j == row . Length )
97
97
{
98
98
j = 0 ;
99
99
i ++ ;
@@ -137,9 +137,9 @@ private void WritePixels<TPixel>(Image<TPixel> image, Stream stream)
137
137
diffBlue = ( sbyte ) ( currentRgba32 . B - previousPixel . B ) ;
138
138
139
139
// 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 &&
143
143
currentRgba32 . A == previousPixel . A )
144
144
{
145
145
// Bottom limit is -2, so we add 2 to make it equal to 0
@@ -155,9 +155,9 @@ diffBlue is > -3 and < 2 &&
155
155
// If so, we do a QOI_OP_LUMA
156
156
sbyte diffRedGreen = ( sbyte ) ( diffRed - diffGreen ) ,
157
157
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 &&
161
161
currentRgba32 . A == previousPixel . A )
162
162
{
163
163
byte dr_dg = ( byte ) ( diffRedGreen + 8 ) ,
0 commit comments