UIImage(ForceDecode)

@interface UIImage (ForceDecode)

UIImage category about force decode feature (avoid Image/IO’s lazy decoding during rendering behavior).

  • A bool value indicating whether the image has already been decoded. This can help to avoid extra force decode.

    Declaration

    Objective-C

    @property (nonatomic) BOOL sd_isDecoded;

    Swift

    var sd_isDecoded: Bool { get set }
  • Decode the provided image. This is useful if you want to force decode the image before rendering to improve performance.

    Declaration

    Objective-C

    + (nullable UIImage *)sd_decodedImageWithImage:(nullable UIImage *)image;

    Swift

    class func sd_decodedImage(with image: UIImage?) -> UIImage?

    Parameters

    image

    The image to be decoded

    Return Value

    The decoded image

  • Decode and scale down the provided image

    Declaration

    Objective-C

    + (nullable UIImage *)sd_decodedAndScaledDownImageWithImage:
        (nullable UIImage *)image;

    Swift

    class func sd_decodedAndScaledDownImage(with image: UIImage?) -> UIImage?

    Parameters

    image

    The image to be decoded

    Return Value

    The decoded and scaled down image

  • Decode and scale down the provided image with limit bytes

    Declaration

    Objective-C

    + (nullable UIImage *)sd_decodedAndScaledDownImageWithImage:
                              (nullable UIImage *)image
                                                     limitBytes:(NSUInteger)bytes;

    Swift

    class func sd_decodedAndScaledDownImage(with image: UIImage?, limitBytes bytes: UInt) -> UIImage?

    Parameters

    image

    The image to be decoded

    bytes

    The limit bytes size. Provide 0 to use the build-in limit.

    Return Value

    The decoded and scaled down image