UIImage(SBSDKFiltersAndWarping)

@interface UIImage (SBSDKFiltersAndWarping)

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

  • 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 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.