@@ -76,6 +76,7 @@ private static void WriteGrayscale<TPixel>(Configuration configuration, Stream s
7676 {
7777 int width = image . Width ;
7878 int height = image . Height ;
79+ Buffer2D < TPixel > pixelBuffer = image . PixelBuffer ;
7980 MemoryAllocator allocator = configuration . MemoryAllocator ;
8081 using IMemoryOwner < L8 > row = allocator . Allocate < L8 > ( width ) ;
8182 Span < L8 > rowSpan = row . GetSpan ( ) ;
@@ -84,7 +85,7 @@ private static void WriteGrayscale<TPixel>(Configuration configuration, Stream s
8485
8586 for ( int y = 0 ; y < height ; y ++ )
8687 {
87- Span < TPixel > pixelSpan = image . GetPixelRowSpan ( y ) ;
88+ Span < TPixel > pixelSpan = pixelBuffer . DangerousGetRowSpan ( y ) ;
8889 PixelOperations < TPixel > . Instance . ToL8 (
8990 configuration ,
9091 pixelSpan ,
@@ -108,6 +109,7 @@ private static void WriteWideGrayscale<TPixel>(Configuration configuration, Stre
108109 {
109110 int width = image . Width ;
110111 int height = image . Height ;
112+ Buffer2D < TPixel > pixelBuffer = image . PixelBuffer ;
111113 MemoryAllocator allocator = configuration . MemoryAllocator ;
112114 using IMemoryOwner < L16 > row = allocator . Allocate < L16 > ( width ) ;
113115 Span < L16 > rowSpan = row . GetSpan ( ) ;
@@ -116,7 +118,7 @@ private static void WriteWideGrayscale<TPixel>(Configuration configuration, Stre
116118
117119 for ( int y = 0 ; y < height ; y ++ )
118120 {
119- Span < TPixel > pixelSpan = image . GetPixelRowSpan ( y ) ;
121+ Span < TPixel > pixelSpan = pixelBuffer . DangerousGetRowSpan ( y ) ;
120122 PixelOperations < TPixel > . Instance . ToL16 (
121123 configuration ,
122124 pixelSpan ,
@@ -140,6 +142,7 @@ private static void WriteRgb<TPixel>(Configuration configuration, Stream stream,
140142 {
141143 int width = image . Width ;
142144 int height = image . Height ;
145+ Buffer2D < TPixel > pixelBuffer = image . PixelBuffer ;
143146 MemoryAllocator allocator = configuration . MemoryAllocator ;
144147 using IMemoryOwner < Rgb24 > row = allocator . Allocate < Rgb24 > ( width ) ;
145148 Span < Rgb24 > rowSpan = row . GetSpan ( ) ;
@@ -148,7 +151,7 @@ private static void WriteRgb<TPixel>(Configuration configuration, Stream stream,
148151
149152 for ( int y = 0 ; y < height ; y ++ )
150153 {
151- Span < TPixel > pixelSpan = image . GetPixelRowSpan ( y ) ;
154+ Span < TPixel > pixelSpan = pixelBuffer . DangerousGetRowSpan ( y ) ;
152155 PixelOperations < TPixel > . Instance . ToRgb24 (
153156 configuration ,
154157 pixelSpan ,
@@ -178,6 +181,7 @@ private static void WriteWideRgb<TPixel>(Configuration configuration, Stream str
178181 {
179182 int width = image . Width ;
180183 int height = image . Height ;
184+ Buffer2D < TPixel > pixelBuffer = image . PixelBuffer ;
181185 MemoryAllocator allocator = configuration . MemoryAllocator ;
182186 using IMemoryOwner < Rgb48 > row = allocator . Allocate < Rgb48 > ( width ) ;
183187 Span < Rgb48 > rowSpan = row . GetSpan ( ) ;
@@ -186,7 +190,7 @@ private static void WriteWideRgb<TPixel>(Configuration configuration, Stream str
186190
187191 for ( int y = 0 ; y < height ; y ++ )
188192 {
189- Span < TPixel > pixelSpan = image . GetPixelRowSpan ( y ) ;
193+ Span < TPixel > pixelSpan = pixelBuffer . DangerousGetRowSpan ( y ) ;
190194 PixelOperations < TPixel > . Instance . ToRgb48 (
191195 configuration ,
192196 pixelSpan ,
@@ -216,6 +220,7 @@ private static void WriteBlackAndWhite<TPixel>(Configuration configuration, Stre
216220 {
217221 int width = image . Width ;
218222 int height = image . Height ;
223+ Buffer2D < TPixel > pixelBuffer = image . PixelBuffer ;
219224 MemoryAllocator allocator = configuration . MemoryAllocator ;
220225 using IMemoryOwner < L8 > row = allocator . Allocate < L8 > ( width ) ;
221226 Span < L8 > rowSpan = row . GetSpan ( ) ;
@@ -224,7 +229,7 @@ private static void WriteBlackAndWhite<TPixel>(Configuration configuration, Stre
224229
225230 for ( int y = 0 ; y < height ; y ++ )
226231 {
227- Span < TPixel > pixelSpan = image . GetPixelRowSpan ( y ) ;
232+ Span < TPixel > pixelSpan = pixelBuffer . DangerousGetRowSpan ( y ) ;
228233 PixelOperations < TPixel > . Instance . ToL8 (
229234 configuration ,
230235 pixelSpan ,
0 commit comments