Merge pull request #2973 from dreampiggy/behavior_uttype_from_unkown_format
Change the behavior to return the abstract type for unknown image format, this can solve the accident issue for custom coder who provide a new format
This commit is contained in:
commit
83a40c3679
|
@ -45,6 +45,7 @@ static const SDImageFormat SDImageFormatSVG = 8;
|
|||
*
|
||||
* @param format Format as SDImageFormat
|
||||
* @return The UTType as CFStringRef
|
||||
* @note For unknown format, `kUTTypeImage` abstract type will return
|
||||
*/
|
||||
+ (nonnull CFStringRef)sd_UTTypeFromImageFormat:(SDImageFormat)format CF_RETURNS_NOT_RETAINED NS_SWIFT_NAME(sd_UTType(from:));
|
||||
|
||||
|
@ -53,6 +54,7 @@ static const SDImageFormat SDImageFormatSVG = 8;
|
|||
*
|
||||
* @param uttype The UTType as CFStringRef
|
||||
* @return The Format as SDImageFormat
|
||||
* @note For unknown type, `SDImageFormatUndefined` will return
|
||||
*/
|
||||
+ (SDImageFormat)sd_imageFormatFromUTType:(nonnull CFStringRef)uttype;
|
||||
|
||||
|
|
|
@ -119,8 +119,8 @@
|
|||
UTType = kUTTypeScalableVectorGraphics;
|
||||
break;
|
||||
default:
|
||||
// default is kUTTypePNG
|
||||
UTType = kUTTypePNG;
|
||||
// default is kUTTypeImage abstract type
|
||||
UTType = kUTTypeImage;
|
||||
break;
|
||||
}
|
||||
return UTType;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
// Test invalid format
|
||||
CFStringRef type = [NSData sd_UTTypeFromImageFormat:SDImageFormatUndefined];
|
||||
expect(CFStringCompare(kUTTypePNG, type, 0)).equal(kCFCompareEqualTo);
|
||||
expect(CFStringCompare(kUTTypeImage, type, 0)).equal(kCFCompareEqualTo);
|
||||
expect([NSData sd_imageFormatFromUTType:kUTTypeImage]).equal(SDImageFormatUndefined);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue