RCTImageUtils Obj-C nullability annotations

Summary:
Add Objective-C nullability annotations to RCTImageUtils

public

Reviewed By: nicklockwood

Differential Revision: D2797310

fb-gh-sync-id: 08329f70d1a09bf47865c9e7e76d7b4340eb6e80
This commit is contained in:
Milen Dzhumerov 2016-01-06 03:54:25 -08:00 committed by facebook-github-bot-4
parent f421d2b056
commit 7d70b86a7b
2 changed files with 16 additions and 12 deletions

View File

@ -12,6 +12,8 @@
#import "RCTDefines.h"
NS_ASSUME_NONNULL_BEGIN
/**
* This function takes an input content size (typically from an image), a target
* size and scale that it will be drawn at (typically in a CGContext) and then
@ -53,16 +55,16 @@ RCT_EXTERN CGSize RCTSizeInPixels(CGSize pointSize, CGFloat scale);
* width/height of the returned image is guaranteed to be >= destSize.
* Pass a destSize of CGSizeZero to decode the image at its original size.
*/
RCT_EXTERN UIImage *RCTDecodeImageWithData(NSData *data,
CGSize destSize,
CGFloat destScale,
UIViewContentMode resizeMode);
RCT_EXTERN UIImage *__nullable RCTDecodeImageWithData(NSData *data,
CGSize destSize,
CGFloat destScale,
UIViewContentMode resizeMode);
/**
* This function takes the source data for an image and decodes just the
* metadata, without decompressing the image itself.
*/
RCT_EXTERN NSDictionary<NSString *, id> *RCTGetImageMetadata(NSData *data);
RCT_EXTERN NSDictionary<NSString *, id> *__nullable RCTGetImageMetadata(NSData *data);
/**
* Convert an image back into data. Images with an alpha channel will be
@ -71,4 +73,6 @@ RCT_EXTERN NSDictionary<NSString *, id> *RCTGetImageMetadata(NSData *data);
* conversion, with 1.0 being maximum quality. It has no effect for images
* using PNG compression.
*/
RCT_EXTERN NSData *RCTGetImageData(CGImageRef image, float quality);
RCT_EXTERN NSData *__nullable RCTGetImageData(CGImageRef image, float quality);
NS_ASSUME_NONNULL_END

View File

@ -207,10 +207,10 @@ CGSize RCTSizeInPixels(CGSize pointSize, CGFloat scale)
};
}
UIImage *RCTDecodeImageWithData(NSData *data,
CGSize destSize,
CGFloat destScale,
UIViewContentMode resizeMode)
UIImage *__nullable RCTDecodeImageWithData(NSData *data,
CGSize destSize,
CGFloat destScale,
UIViewContentMode resizeMode)
{
CGImageSourceRef sourceRef = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
if (!sourceRef) {
@ -265,7 +265,7 @@ UIImage *RCTDecodeImageWithData(NSData *data,
return image;
}
NSDictionary<NSString *, id> *RCTGetImageMetadata(NSData *data)
NSDictionary<NSString *, id> *__nullable RCTGetImageMetadata(NSData *data)
{
CGImageSourceRef sourceRef = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
if (!sourceRef) {
@ -276,7 +276,7 @@ NSDictionary<NSString *, id> *RCTGetImageMetadata(NSData *data)
return (__bridge_transfer id)imageProperties;
}
NSData *RCTGetImageData(CGImageRef image, float quality)
NSData *__nullable RCTGetImageData(CGImageRef image, float quality)
{
NSDictionary *properties;
CGImageDestinationRef destination;