diff --git a/SDWebImage/NSData+ImageContentType.h b/SDWebImage/NSData+ImageContentType.h index 2a9f7e2b..c5970cb4 100644 --- a/SDWebImage/NSData+ImageContentType.h +++ b/SDWebImage/NSData+ImageContentType.h @@ -10,15 +10,18 @@ #import #import "SDWebImageCompat.h" -typedef NS_ENUM(NSInteger, SDImageFormat) { - SDImageFormatUndefined = -1, - SDImageFormatJPEG = 0, - SDImageFormatPNG, - SDImageFormatGIF, - SDImageFormatTIFF, - SDImageFormatWebP, - SDImageFormatHEIC -}; +/** + You can use switch case like normal enum. It's also recommended to add a default case. You should not assume anything about the raw value. + For custom coder plugin, it can also extern the enum for supported format. See `SDImageCoder` for more detailed information. + */ +typedef NSInteger SDImageFormat NS_TYPED_EXTENSIBLE_ENUM; +static const SDImageFormat SDImageFormatUndefined = -1; +static const SDImageFormat SDImageFormatJPEG = 0; +static const SDImageFormat SDImageFormatPNG = 1; +static const SDImageFormat SDImageFormatGIF = 2; +static const SDImageFormat SDImageFormatTIFF = 3; +static const SDImageFormat SDImageFormatWebP = 4; +static const SDImageFormat SDImageFormatHEIC = 5; @interface NSData (ImageContentType) diff --git a/SDWebImage/SDImageCoder.h b/SDWebImage/SDImageCoder.h index ebf151b2..d6c7a735 100644 --- a/SDWebImage/SDImageCoder.h +++ b/SDWebImage/SDImageCoder.h @@ -72,6 +72,10 @@ FOUNDATION_EXPORT SDImageCoderOption _Nonnull const SDImageCoderEncodeCompressio /** Returns YES if this coder can encode some image. Otherwise, it should be passed to another coder. + For custom coder which introduce new image format, you'd better define a new `SDImageFormat` using like this. If you're creating public coder plugin for new image format, also update `https://github.com/rs/SDWebImage/wiki/Coder-Plugin-List` to avoid same value been defined twice. + * @code + static const SDImageFormat SDImageFormatHEIF = 10; + * @endcode @param format The image format @return YES if this coder can encode the image, NO otherwise