|
1 | 1 | // Copyright (c) Six Labors. |
2 | 2 | // Licensed under the Six Labors Split License. |
3 | 3 |
|
4 | | -using System.Runtime.CompilerServices; |
5 | | - |
6 | 4 | namespace SixLabors.ImageSharp.Formats.Jpeg; |
7 | 5 |
|
8 | 6 | internal static class JpegThrowHelper |
9 | 7 | { |
10 | | - /// <summary> |
11 | | - /// Cold path optimization for throwing <see cref="NotSupportedException"/>'s. |
12 | | - /// </summary> |
13 | | - /// <param name="errorMessage">The error message for the exception.</param> |
14 | | - [MethodImpl(InliningOptions.ColdPath)] |
15 | 8 | public static void ThrowNotSupportedException(string errorMessage) => throw new NotSupportedException(errorMessage); |
16 | 9 |
|
17 | | - /// <summary> |
18 | | - /// Cold path optimization for throwing <see cref="InvalidImageContentException"/>'s. |
19 | | - /// </summary> |
20 | | - /// <param name="errorMessage">The error message for the exception.</param> |
21 | | - [MethodImpl(InliningOptions.ColdPath)] |
22 | 10 | public static void ThrowInvalidImageContentException(string errorMessage) => throw new InvalidImageContentException(errorMessage); |
23 | 11 |
|
24 | | - [MethodImpl(InliningOptions.ColdPath)] |
25 | 12 | public static void ThrowBadMarker(string marker, int length) => throw new InvalidImageContentException($"Marker {marker} has bad length {length}."); |
26 | 13 |
|
27 | | - [MethodImpl(InliningOptions.ColdPath)] |
28 | 14 | public static void ThrowNotEnoughBytesForMarker(byte marker) => throw new InvalidImageContentException($"Input stream does not have enough bytes to parse declared contents of the {marker:X2} marker."); |
29 | 15 |
|
30 | | - [MethodImpl(InliningOptions.ColdPath)] |
31 | 16 | public static void ThrowBadQuantizationTableIndex(int index) => throw new InvalidImageContentException($"Bad Quantization Table index {index}."); |
32 | 17 |
|
33 | | - [MethodImpl(InliningOptions.ColdPath)] |
34 | 18 | public static void ThrowBadQuantizationTablePrecision(int precision) => throw new InvalidImageContentException($"Unknown Quantization Table precision {precision}."); |
35 | 19 |
|
36 | | - [MethodImpl(InliningOptions.ColdPath)] |
37 | 20 | public static void ThrowBadSampling() => throw new InvalidImageContentException("Bad sampling factor."); |
38 | 21 |
|
39 | | - [MethodImpl(InliningOptions.ColdPath)] |
40 | 22 | public static void ThrowBadSampling(int factor) => throw new InvalidImageContentException($"Bad sampling factor: {factor}"); |
41 | 23 |
|
42 | | - [MethodImpl(InliningOptions.ColdPath)] |
43 | 24 | public static void ThrowBadProgressiveScan(int ss, int se, int ah, int al) => throw new InvalidImageContentException($"Invalid progressive parameters Ss={ss} Se={se} Ah={ah} Al={al}."); |
44 | 25 |
|
45 | | - [MethodImpl(InliningOptions.ColdPath)] |
46 | 26 | public static void ThrowInvalidImageDimensions(int width, int height) => throw new InvalidImageContentException($"Invalid image dimensions: {width}x{height}."); |
47 | 27 |
|
48 | | - [MethodImpl(InliningOptions.ColdPath)] |
49 | 28 | public static void ThrowDimensionsTooLarge(int width, int height) => throw new ImageFormatException($"Image is too large to encode at {width}x{height} for JPEG format."); |
50 | 29 |
|
51 | | - [MethodImpl(InliningOptions.ColdPath)] |
52 | 30 | public static void ThrowNotSupportedComponentCount(int componentCount) => throw new NotSupportedException($"Images with {componentCount} components are not supported."); |
53 | 31 |
|
54 | | - [MethodImpl(InliningOptions.ColdPath)] |
55 | 32 | public static void ThrowNotSupportedColorSpace() => throw new NotSupportedException("Image color space could not be deduced."); |
56 | 33 | } |
0 commit comments