@@ -259,7 +259,7 @@ public void ParseStream(Stream stream, bool metadataOnly = false)
259259 var fileMarker = new JpegFileMarker ( this . markerBuffer [ 1 ] , 0 ) ;
260260 if ( fileMarker . Marker != JpegConstants . Markers . SOI )
261261 {
262- JpegThrowHelper . ThrowImageFormatException ( "Missing SOI marker." ) ;
262+ JpegThrowHelper . ThrowInvalidImageContentException ( "Missing SOI marker." ) ;
263263 }
264264
265265 this . InputStream . Read ( this . markerBuffer , 0 , 2 ) ;
@@ -423,7 +423,7 @@ private JpegColorSpace DeduceJpegColorSpace()
423423 : JpegColorSpace . Cmyk ;
424424 }
425425
426- JpegThrowHelper . ThrowImageFormatException ( $ "Unsupported color mode. Supported component counts 1, 3, and 4; found { this . ComponentCount } ") ;
426+ JpegThrowHelper . ThrowInvalidImageContentException ( $ "Unsupported color mode. Supported component counts 1, 3, and 4; found { this . ComponentCount } ") ;
427427 return default ;
428428 }
429429
@@ -821,7 +821,7 @@ private void ProcessStartOfFrameMarker(int remaining, in JpegFileMarker frameMar
821821 {
822822 if ( this . Frame != null )
823823 {
824- JpegThrowHelper . ThrowImageFormatException ( "Multiple SOF markers. Only single frame jpegs supported." ) ;
824+ JpegThrowHelper . ThrowInvalidImageContentException ( "Multiple SOF markers. Only single frame jpegs supported." ) ;
825825 }
826826
827827 // Read initial marker definitions.
@@ -831,7 +831,7 @@ private void ProcessStartOfFrameMarker(int remaining, in JpegFileMarker frameMar
831831 // We only support 8-bit and 12-bit precision.
832832 if ( Array . IndexOf ( this . supportedPrecisions , this . temp [ 0 ] ) == - 1 )
833833 {
834- JpegThrowHelper . ThrowImageFormatException ( "Only 8-Bit and 12-Bit precision supported." ) ;
834+ JpegThrowHelper . ThrowInvalidImageContentException ( "Only 8-Bit and 12-Bit precision supported." ) ;
835835 }
836836
837837 this . Precision = this . temp [ 0 ] ;
@@ -928,13 +928,13 @@ private void ProcessDefineHuffmanTablesMarker(int remaining)
928928 // Types 0..1 DC..AC
929929 if ( tableType > 1 )
930930 {
931- JpegThrowHelper . ThrowImageFormatException ( "Bad Huffman Table type." ) ;
931+ JpegThrowHelper . ThrowInvalidImageContentException ( "Bad Huffman Table type." ) ;
932932 }
933933
934934 // Max tables of each type
935935 if ( tableIndex > 3 )
936936 {
937- JpegThrowHelper . ThrowImageFormatException ( "Bad Huffman Table index." ) ;
937+ JpegThrowHelper . ThrowInvalidImageContentException ( "Bad Huffman Table index." ) ;
938938 }
939939
940940 this . InputStream . Read ( huffmanData . Array , 0 , 16 ) ;
@@ -953,7 +953,7 @@ private void ProcessDefineHuffmanTablesMarker(int remaining)
953953
954954 if ( codeLengthSum > 256 || codeLengthSum > length )
955955 {
956- JpegThrowHelper . ThrowImageFormatException ( "Huffman table has excessive length." ) ;
956+ JpegThrowHelper . ThrowInvalidImageContentException ( "Huffman table has excessive length." ) ;
957957 }
958958
959959 using ( IManagedByteBuffer huffmanValues = this . configuration . MemoryAllocator . AllocateManagedByteBuffer ( 256 , AllocationOptions . Clean ) )
@@ -995,7 +995,7 @@ private void ProcessStartOfScanMarker()
995995 {
996996 if ( this . Frame is null )
997997 {
998- JpegThrowHelper . ThrowImageFormatException ( "No readable SOFn (Start Of Frame) marker found." ) ;
998+ JpegThrowHelper . ThrowInvalidImageContentException ( "No readable SOFn (Start Of Frame) marker found." ) ;
999999 }
10001000
10011001 int selectorsCount = this . InputStream . ReadByte ( ) ;
@@ -1016,7 +1016,7 @@ private void ProcessStartOfScanMarker()
10161016
10171017 if ( componentIndex < 0 )
10181018 {
1019- JpegThrowHelper . ThrowImageFormatException ( $ "Unknown component selector { componentIndex } .") ;
1019+ JpegThrowHelper . ThrowInvalidImageContentException ( $ "Unknown component selector { componentIndex } .") ;
10201020 }
10211021
10221022 ref JpegComponent component = ref this . Frame . Components [ componentIndex ] ;
0 commit comments