UIImage(SBSDK)

@interface UIImage (SBSDK)

@category UIImage(SBSDK) An UIImage class extension to perform basic image processing operations. Direct usage is not recommended for large images. Instead use SBSDKImageProcessor methods to employ queues and proper memory management.

  • Creates a UIImage instance from a sample buffer.

    Declaration

    Objective-C

    - (nullable id)sbsdk_initFromSampleBuffer:
        (nonnull CMSampleBufferRef)sampleBuffer;

    Swift

    func sbsdk_init(from sampleBuffer: CMSampleBuffer) -> Any?
  • Converts a CMSampleBuffer to an UIImage.

    Declaration

    Objective-C

    + (nullable UIImage *)sbsdk_imageFromSampleBuffer:
        (nonnull CMSampleBufferRef)sampleBuffer;

    Swift

    class func sbsdk_image(from sampleBuffer: CMSampleBuffer) -> UIImage?

    Parameters

    sampleBuffer

    The sample buffer to convert.

    Return Value

    An UIImage.

  • Applies a filter to the receiver and returns the filtered image.

    Declaration

    Objective-C

    - (nullable UIImage *)sbsdk_imageFilteredByFilter:(SBSDKImageFilterType)filter;

    Swift

    func sbsdk_imageFiltered(by filter: SBSDKImageFilterType) -> UIImage?

    Parameters

    filter

    The type of the filter to be applied.

    Return Value

    The filtered UIImage.

  • Applies a polygon to the receiver and returns the cropped and perspective corrected image.

    Declaration

    Objective-C

    - (nullable UIImage *)sbsdk_imageWarpedByPolygon:(nonnull SBSDKPolygon *)polygon
                                          imageScale:(CGFloat)imageScale;

    Swift

    func sbsdk_imageWarped(by polygon: SBSDKPolygon, imageScale: CGFloat) -> UIImage?

    Parameters

    polygon

    The polygon used to crop and perspective correct the image.

    imageScale

    If the image has been scaled, compared to how it was captured from the camera, you must set the scaling factor here for proper cropping. Otherwise the the resulting aspect ratio will be wrong. Set to 1.0 if the image if of its original size.

    Return Value

    The cropped and perspective corrected UIImage.

  • Applies a polygon to the receiver and returns the cropped and perspective corrected image.

    Declaration

    Objective-C

    - (nullable UIImage *)sbsdk_imageWarpedByPolygon:(nonnull SBSDKPolygon *)polygon
                                lensCameraProperties:
                                    (nullable SBSDKLensCameraProperties *)
                                        lensCameraProperties
                                          imageScale:(CGFloat)imageScale;

    Swift

    func sbsdk_imageWarped(by polygon: SBSDKPolygon, lensCameraProperties: SBSDKLensCameraProperties?, imageScale: CGFloat) -> UIImage?

    Parameters

    polygon

    The polygon used to crop and perspective correct the image.

    lensCameraProperties

    Properties of the camera which captured the image or nil.

    imageScale

    If the image has been scaled, compared to how it was captured from the camera, you must set the scaling factor here for proper cropping. Otherwise the the resulting aspect ratio will be wrong. Set to 1.0 if the image if of its original size.

    Return Value

    The cropped and perspective corrected UIImage.

  • Applies a polygon and a filter to the receiver. Faster than two sequential operations.

    Declaration

    Objective-C

    - (nullable UIImage *)sbsdk_imageWarpedByPolygon:(nonnull SBSDKPolygon *)polygon
                                       andFilteredBy:(SBSDKImageFilterType)filter
                                          imageScale:(CGFloat)imageScale;

    Swift

    func sbsdk_imageWarped(by polygon: SBSDKPolygon, andFilteredBy filter: SBSDKImageFilterType, imageScale: CGFloat) -> UIImage?

    Parameters

    polygon

    The polygon used to crop and perspective correct the image.

    filter

    The type of the filter to be applied.

    imageScale

    If the image has been scaled, compared to how it was captured from the camera, you must set the scaling factor here for proper cropping. Otherwise the the resulting aspect ratio will be wrong. Set to 1.0 if the image if of its original size.

    Return Value

    The cropped and perspective corrected UIImage.

  • Applies a polygon and a filter to the receiver. Faster than two sequential operations.

    Declaration

    Objective-C

    - (nullable UIImage *)sbsdk_imageWarpedByPolygon:(nonnull SBSDKPolygon *)polygon
                                       andFilteredBy:(SBSDKImageFilterType)filter
                                lensCameraProperties:
                                    (nullable SBSDKLensCameraProperties *)
                                        lensCameraProperties
                                          imageScale:(CGFloat)imageScale;

    Swift

    func sbsdk_imageWarped(by polygon: SBSDKPolygon, andFilteredBy filter: SBSDKImageFilterType, lensCameraProperties: SBSDKLensCameraProperties?, imageScale: CGFloat) -> UIImage?

    Parameters

    polygon

    The polygon used to crop and perspective correct the image.

    filter

    The type of the filter to be applied.

    lensCameraProperties

    Properties of the camera which captured the image or nil.

    imageScale

    If the image has been scaled, compared to how it was captured from the camera, you must set the scaling factor here for proper cropping. Otherwise the the resulting aspect ratio will be wrong. Set to 1.0 if the image if of its original size.

    Return Value

    The cropped and perspective corrected UIImage.

  • Applies clockwise 90 degree rotations to the receiver.

    Declaration

    Objective-C

    - (nullable UIImage *)sbsdk_imageRotatedClockwise:(NSInteger)times;

    Swift

    func sbsdk_imageRotatedClockwise(_ times: Int) -> UIImage?

    Parameters

    times

    Number of 90 degree rotations to apply. Can be negative. Uses modulo arithmetics.

    Return Value

    The rotated UIImage.

  • Applies counter-clockwise 90 degree rotations to the receiver.

    Declaration

    Objective-C

    - (nullable UIImage *)sbsdk_imageRotatedCounterClockwise:(NSInteger)times;

    Swift

    func sbsdk_imageRotatedCounterClockwise(_ times: Int) -> UIImage?

    Parameters

    times

    Number of 90 degree rotations to apply. Can be negative. Uses modulo arithmetics.

    Return Value

    The rotated UIImage.

  • Rotates the receiver for the given angle.

    Declaration

    Objective-C

    - (nullable UIImage *)sbsdk_imageRotatedByDegrees:(CGFloat)degrees;

    Swift

    func sbsdk_imageRotated(byDegrees degrees: CGFloat) -> UIImage?

    Return Value

    The rotated image.

  • Applies counter-clockwise 90 degree rotations, polygon warping and filtering to the receiver and returns a JPEG UIImage with given compression/quality.

    Declaration

    Objective-C

    - (nullable UIImage *)
        sbsdk_imageByProcessingWithRotations:(NSInteger)times
                                     polygon:(nullable SBSDKPolygon *)polygon
                                      filter:(SBSDKImageFilterType)filter
                                 compression:(CGFloat)compression
                        lensCameraProperties:(nullable SBSDKLensCameraProperties *)
                                                 lensCameraProperties
                                  imageScale:(CGFloat)imageScale;

    Swift

    func sbsdk_imageByProcessing(withRotations times: Int, polygon: SBSDKPolygon?, filter: SBSDKImageFilterType, compression: CGFloat, lensCameraProperties: SBSDKLensCameraProperties?, imageScale: CGFloat) -> UIImage?

    Parameters

    times

    Number of 90 degree rotations to apply. Can be negative. Uses modulo arithmetics.

    polygon

    The polygon used to crop and perspective correct the image.

    filter

    The type of the filter to be applied.

    compression

    The JPEG compression/quality setting. Range is 0.0 (low quality, small file) to 1.0 (high quality, large file).

    lensCameraProperties

    Properties of the camera which captured the image or nil.

    imageScale

    If the image has been scaled, compared to how it was captured from the camera, you must set the scaling factor here for proper cropping. Otherwise the the resulting aspect ratio will be wrong. Set to 1.0 if the image if of its original size.

    Return Value

    The processed UIImage.

  • Applies counter-clockwise 90 degree rotations, polygon warping and filtering to the receiver and returns JPEG image data with given compression/quality.

    Declaration

    Objective-C

    - (nullable NSData *)
        sbsdk_imageDataByProcessingWithRotations:(NSInteger)times
                                         polygon:(nullable SBSDKPolygon *)polygon
                                          filter:(SBSDKImageFilterType)filter
                                     compression:(CGFloat)compression
                            lensCameraProperties:
                                (nullable SBSDKLensCameraProperties *)
                                    lensCameraProperties
                                      imageScale:(CGFloat)imageScale;

    Swift

    func sbsdk_imageDataByProcessing(withRotations times: Int, polygon: SBSDKPolygon?, filter: SBSDKImageFilterType, compression: CGFloat, lensCameraProperties: SBSDKLensCameraProperties?, imageScale: CGFloat) -> Data?

    Parameters

    times

    Number of 90 degree rotations to apply. Can be negative. Uses modulo arithmetics.

    polygon

    The polygon used to crop and perspective correct the image.

    filter

    The type of the filter to be applied.

    compression

    The JPEG compression/quality setting. Range is 0.0 (low quality, small file) to 1.0 (high quality, large file).

    lensCameraProperties

    Properties of the camera which captured the image or nil.

    imageScale

    If the image has been scaled, compared to how it was captured from the camera, you must set the scaling factor here for proper cropping. Otherwise the the resulting aspect ratio will be wrong. Set to 1.0 if the image if of its original size.

    Return Value

    The JPEG data of the processed image.

  • Applies the an image filter to the receiver and returns JPEG image data with given compression/quality.

    Declaration

    Objective-C

    - (nullable NSData *)sbsdk_imageDataByApplyingFilter:
                             (SBSDKImageFilterType)filter
                                             compression:(CGFloat)compression;

    Swift

    func sbsdk_imageData(byApplying filter: SBSDKImageFilterType, compression: CGFloat) -> Data?

    Parameters

    filter

    The type of the filter to be applied.

    compression

    The JPEG compression/quality setting. Range is 0.0 (low quality, small file) to 1.0 (high quality, large file).

    Return Value

    The JPEG data of the processed image.

  • Rotates the receiver and corrects the orientation flag to UIImageOrientationUp.

    Declaration

    Objective-C

    - (nullable UIImage *)sbsdk_imageWithNormalizedOrientation;

    Swift

    func sbsdk_imageWithNormalizedOrientation() -> UIImage?

    Return Value

    The orientation fixed image.

  • Resets the orientation flag to UIImageOrientationUp without rotating the image data.

    Declaration

    Objective-C

    - (nullable UIImage *)sbsdk_imageWithFixedOrientation;

    Swift

    func sbsdk_imageWithFixedOrientation() -> UIImage?

    Return Value

    Image with modified orientation metadata.

  • Strips the alpha channel from an image.

    Declaration

    Objective-C

    - (nullable UIImage *)sbsdk_imageWithStrippedAlpha;

    Swift

    func sbsdk_imageWithStrippedAlpha() -> UIImage?

    Return Value

    The image without alpha channel.

  • Inverts the colors of the receiver.

    Declaration

    Objective-C

    - (nullable UIImage *)sbsdk_invertedImage;

    Swift

    func sbsdk_inverted() -> UIImage?

    Return Value

    The inverted image.

  • Scales down the image to fit into the given size. Does no upscaling. Does nothing, if width or height equal to zero.

    Declaration

    Objective-C

    - (nullable UIImage *)sbsdk_limitedToSize:(CGSize)imageSize;

    Swift

    func sbsdk_limited(to imageSize: CGSize) -> UIImage?
  • Resets the orientation flag to UIImageOrientationUp without rotating the image data.

    Declaration

    Objective-C

    + (nullable NSData *)sbsdk_imageDataWithFixedOrientation:
        (nullable NSData *)imageData;

    Swift

    class func sbsdk_imageData(withFixedOrientation imageData: Data?) -> Data?

    Return Value

    A new NSData instance containing jpeg image data with corrected metadata.

  • Analyzes and returns the metrics of the receiver.

    Declaration

    Objective-C

    - (nonnull NSArray<SBSDKImageChannelMetrics *> *)sbsdk_analyzeMetrics;

    Swift

    func sbsdk_analyzeMetrics() -> [SBSDKImageChannelMetrics]

    Return Value

    A SBSDKImageChannelMetrics object.

  • Undocumented

    Declaration

    Objective-C

    + (NSInteger)proposedCounterClockwiseRotationsForOrientation:(UIDeviceOrientation)deviceOrientation;

    Swift

    class func proposedCounterClockwiseRotations(for deviceOrientation: UIDeviceOrientation) -> Int