@@ -167,10 +167,14 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream, CancellationToken
167167 /// <param name="colorType">The color type.</param>
168168 /// <returns>true, if color type is supported.</returns>
169169 private static bool IsSupportedColorType ( JpegColorType ? colorType )
170- => colorType == JpegColorType . YCbCrRatio444
171- || colorType == JpegColorType . YCbCrRatio420
172- || colorType == JpegColorType . Luminance
173- || colorType == JpegColorType . Rgb ;
170+ {
171+ if ( colorType == JpegColorType . YCbCrRatio444 || colorType == JpegColorType . YCbCrRatio420 || colorType == JpegColorType . Luminance || colorType == JpegColorType . Rgb )
172+ {
173+ return true ;
174+ }
175+
176+ return false ;
177+ }
174178
175179 /// <summary>
176180 /// Gets the component ids.
@@ -567,14 +571,14 @@ private void WriteStartOfFrame(int width, int height, int componentCount, ReadOn
567571 // This uses a C#'s compiler optimization that refers to the static data segment of the assembly,
568572 // and doesn't incur any allocation at all.
569573 // "default" to 4:2:0
570- ReadOnlySpan < byte > subsamples = stackalloc byte [ ]
574+ ReadOnlySpan < byte > subsamples = new byte [ ]
571575 {
572576 0x22 ,
573577 0x11 ,
574578 0x11
575579 } ;
576580
577- ReadOnlySpan < byte > chroma = stackalloc byte [ ]
581+ ReadOnlySpan < byte > chroma = new byte [ ]
578582 {
579583 0x00 ,
580584 0x01 ,
@@ -583,7 +587,7 @@ private void WriteStartOfFrame(int width, int height, int componentCount, ReadOn
583587
584588 if ( this . colorType == JpegColorType . Luminance )
585589 {
586- subsamples = stackalloc byte [ ]
590+ subsamples = new byte [ ]
587591 {
588592 0x11 ,
589593 0x00 ,
@@ -596,7 +600,7 @@ private void WriteStartOfFrame(int width, int height, int componentCount, ReadOn
596600 {
597601 case JpegColorType . YCbCrRatio444 :
598602 case JpegColorType . Rgb :
599- subsamples = stackalloc byte [ ]
603+ subsamples = new byte [ ]
600604 {
601605 0x11 ,
602606 0x11 ,
@@ -605,7 +609,7 @@ private void WriteStartOfFrame(int width, int height, int componentCount, ReadOn
605609
606610 if ( this . colorType == JpegColorType . Rgb )
607611 {
608- chroma = stackalloc byte [ ]
612+ chroma = new byte [ ]
609613 {
610614 0x00 ,
611615 0x00 ,
@@ -615,7 +619,7 @@ private void WriteStartOfFrame(int width, int height, int componentCount, ReadOn
615619
616620 break ;
617621 case JpegColorType . YCbCrRatio420 :
618- subsamples = stackalloc byte [ ]
622+ subsamples = new byte [ ]
619623 {
620624 0x22 ,
621625 0x11 ,
@@ -658,7 +662,7 @@ private void WriteStartOfScan(int componentCount, ReadOnlySpan<byte> componentId
658662 {
659663 // This uses a C#'s compiler optimization that refers to the static data segment of the assembly,
660664 // and doesn't incur any allocation at all.
661- ReadOnlySpan < byte > huffmanId = stackalloc byte [ ]
665+ ReadOnlySpan < byte > huffmanId = new byte [ ]
662666 {
663667 0x00 ,
664668 0x11 ,
@@ -668,7 +672,7 @@ private void WriteStartOfScan(int componentCount, ReadOnlySpan<byte> componentId
668672 // Use the same DC/AC tables for all channels for RGB.
669673 if ( this . colorType == JpegColorType . Rgb )
670674 {
671- huffmanId = stackalloc byte [ ]
675+ huffmanId = new byte [ ]
672676 {
673677 0x00 ,
674678 0x00 ,
0 commit comments