Tuya iOS Smart Life App SDK 5.15.0
ThingEncryptImageDecoder Class Reference

#import <ThingEncryptImageCoder.h>

Inheritance diagram for ThingEncryptImageDecoder:

Instance Methods

(instancetype) - initWithScale:
 
(BOOL) - updateData:final:
 
(nullable ThingEncryptImageFrame *) - frameAtIndex:decodeForDisplay:
 
(NSTimeInterval) - frameDurationAtIndex:
 
(nullable NSDictionary *) - framePropertiesAtIndex:
 
(nullable NSDictionary *) - imageProperties
 
(instancetype) - initWithScale:
 
(BOOL) - updateData:final:
 
(nullable ThingEncryptImageFrame *) - frameAtIndex:decodeForDisplay:
 
(NSTimeInterval) - frameDurationAtIndex:
 
(nullable NSDictionary *) - framePropertiesAtIndex:
 
(nullable NSDictionary *) - imageProperties
 
(instancetype) - initWithScale:
 
(BOOL) - updateData:final:
 
(nullable ThingEncryptImageFrame *) - frameAtIndex:decodeForDisplay:
 
(NSTimeInterval) - frameDurationAtIndex:
 
(nullable NSDictionary *) - framePropertiesAtIndex:
 
(nullable NSDictionary *) - imageProperties
 
(instancetype) - initWithScale:
 
(BOOL) - updateData:final:
 
(nullable ThingEncryptImageFrame *) - frameAtIndex:decodeForDisplay:
 
(NSTimeInterval) - frameDurationAtIndex:
 
(nullable NSDictionary *) - framePropertiesAtIndex:
 
(nullable NSDictionary *) - imageProperties
 

Class Methods

(nullable instancetype) + decoderWithData:scale:
 
(nullable instancetype) + decoderWithData:scale:
 
(nullable instancetype) + decoderWithData:scale:
 
(nullable instancetype) + decoderWithData:scale:
 

Properties

NSData * data
 Image data. More...
 
ThingEncryptImageType type
 Image data type. More...
 
CGFloat scale
 Image scale. More...
 
NSUInteger frameCount
 Image frame count. More...
 
NSUInteger loopCount
 Image loop count, 0 means infinite. More...
 
NSUInteger width
 Image canvas width. More...
 
NSUInteger height
 Image canvas height. More...
 
BOOL finalized
 

Detailed Description

An image decoder to decode image data.

@discussion This class supports decoding animated WebP, APNG, GIF and system image format such as PNG, JPG, JP2, BMP, TIFF, PIC, ICNS and ICO. It can be used to decode complete image data, or to decode incremental image data during image download. This class is thread-safe.

Example:

Decode single image: NSData *data = [NSData dataWithContentOfFile:"/tmp/image.webp"]; ThingImageDecoder *decoder = [ThingImageDecoder decoderWithData:data scale:2.0]; UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image;

Decode image during download: NSMutableData *data = [NSMutableData new]; ThingImageDecoder *decoder = [[ThingImageDecoder alloc] initWithScale:2.0]; while(newDataArrived) { [data appendData:newData]; [decoder updateData:data final:NO]; if (decoder.frameCount > 0) { UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image; progressive display... } } [decoder updateData:data final:YES]; UIImage image = [decoder frameAtIndex:0 decodeForDisplay:YES].image; final display...

Definition at line 107 of file ThingEncryptImageCoder.h.

Method Documentation

◆ decoderWithData:scale: [1/4]

+ (nullable instancetype) decoderWithData: (NSData *)  data
scale: (CGFloat)  scale 

Convenience method to create a decoder with specified data.

Parameters
dataImage data.
scaleImage's scale.
Returns
A new decoder, or nil if an error occurs.

◆ decoderWithData:scale: [2/4]

+ (nullable instancetype) decoderWithData: (NSData *)  data
scale: (CGFloat)  scale 

Convenience method to create a decoder with specified data.

Parameters
dataImage data.
scaleImage's scale.
Returns
A new decoder, or nil if an error occurs.

◆ decoderWithData:scale: [3/4]

+ (nullable instancetype) decoderWithData: (NSData *)  data
scale: (CGFloat)  scale 

Convenience method to create a decoder with specified data.

Parameters
dataImage data.
scaleImage's scale.
Returns
A new decoder, or nil if an error occurs.

◆ decoderWithData:scale: [4/4]

+ (nullable instancetype) decoderWithData: (NSData *)  data
scale: (CGFloat)  scale 

Convenience method to create a decoder with specified data.

Parameters
dataImage data.
scaleImage's scale.
Returns
A new decoder, or nil if an error occurs.

◆ frameAtIndex:decodeForDisplay: [1/4]

- (nullable ThingEncryptImageFrame *) frameAtIndex: (NSUInteger)  index
decodeForDisplay: (BOOL)  decodeForDisplay 

Decodes and returns a frame from a specified index.

Parameters
indexFrame image index (zero-based).
decodeForDisplayWhether decode the image to memory bitmap for display. If NO, it will try to returns the original frame data without blend.
Returns
A new frame with image, or nil if an error occurs.

◆ frameAtIndex:decodeForDisplay: [2/4]

- (nullable ThingEncryptImageFrame *) frameAtIndex: (NSUInteger)  index
decodeForDisplay: (BOOL)  decodeForDisplay 

Decodes and returns a frame from a specified index.

Parameters
indexFrame image index (zero-based).
decodeForDisplayWhether decode the image to memory bitmap for display. If NO, it will try to returns the original frame data without blend.
Returns
A new frame with image, or nil if an error occurs.

◆ frameAtIndex:decodeForDisplay: [3/4]

- (nullable ThingEncryptImageFrame *) frameAtIndex: (NSUInteger)  index
decodeForDisplay: (BOOL)  decodeForDisplay 

Decodes and returns a frame from a specified index.

Parameters
indexFrame image index (zero-based).
decodeForDisplayWhether decode the image to memory bitmap for display. If NO, it will try to returns the original frame data without blend.
Returns
A new frame with image, or nil if an error occurs.

◆ frameAtIndex:decodeForDisplay: [4/4]

- (nullable ThingEncryptImageFrame *) frameAtIndex: (NSUInteger)  index
decodeForDisplay: (BOOL)  decodeForDisplay 

Decodes and returns a frame from a specified index.

Parameters
indexFrame image index (zero-based).
decodeForDisplayWhether decode the image to memory bitmap for display. If NO, it will try to returns the original frame data without blend.
Returns
A new frame with image, or nil if an error occurs.

◆ frameDurationAtIndex: [1/4]

- (NSTimeInterval) frameDurationAtIndex: (NSUInteger)  index

Returns the frame duration from a specified index.

Parameters
indexFrame image (zero-based).
Returns
Duration in seconds.

◆ frameDurationAtIndex: [2/4]

- (NSTimeInterval) frameDurationAtIndex: (NSUInteger)  index

Returns the frame duration from a specified index.

Parameters
indexFrame image (zero-based).
Returns
Duration in seconds.

◆ frameDurationAtIndex: [3/4]

- (NSTimeInterval) frameDurationAtIndex: (NSUInteger)  index

Returns the frame duration from a specified index.

Parameters
indexFrame image (zero-based).
Returns
Duration in seconds.

◆ frameDurationAtIndex: [4/4]

- (NSTimeInterval) frameDurationAtIndex: (NSUInteger)  index

Returns the frame duration from a specified index.

Parameters
indexFrame image (zero-based).
Returns
Duration in seconds.

◆ framePropertiesAtIndex: [1/4]

- (nullable NSDictionary *) framePropertiesAtIndex: (NSUInteger)  index

Returns the frame's properties. See "CGImageProperties.h" in ImageIO.framework for more information.

Parameters
indexFrame image index (zero-based).
Returns
The ImageIO frame property.

◆ framePropertiesAtIndex: [2/4]

- (nullable NSDictionary *) framePropertiesAtIndex: (NSUInteger)  index

Returns the frame's properties. See "CGImageProperties.h" in ImageIO.framework for more information.

Parameters
indexFrame image index (zero-based).
Returns
The ImageIO frame property.

◆ framePropertiesAtIndex: [3/4]

- (nullable NSDictionary *) framePropertiesAtIndex: (NSUInteger)  index

Returns the frame's properties. See "CGImageProperties.h" in ImageIO.framework for more information.

Parameters
indexFrame image index (zero-based).
Returns
The ImageIO frame property.

◆ framePropertiesAtIndex: [4/4]

- (nullable NSDictionary *) framePropertiesAtIndex: (NSUInteger)  index

Returns the frame's properties. See "CGImageProperties.h" in ImageIO.framework for more information.

Parameters
indexFrame image index (zero-based).
Returns
The ImageIO frame property.

◆ imageProperties [1/4]

- (nullable NSDictionary *) imageProperties

Returns the image's properties. See "CGImageProperties.h" in ImageIO.framework for more information.

◆ imageProperties [2/4]

- (nullable NSDictionary *) imageProperties

Returns the image's properties. See "CGImageProperties.h" in ImageIO.framework for more information.

◆ imageProperties [3/4]

- (nullable NSDictionary *) imageProperties

Returns the image's properties. See "CGImageProperties.h" in ImageIO.framework for more information.

◆ imageProperties [4/4]

- (nullable NSDictionary *) imageProperties

Returns the image's properties. See "CGImageProperties.h" in ImageIO.framework for more information.

◆ initWithScale: [1/4]

- (instancetype) initWithScale: (CGFloat)  NS_DESIGNATED_INITIALIZER

Creates an image decoder.

Parameters
scaleImage's scale.
Returns
An image decoder.

◆ initWithScale: [2/4]

- (instancetype) initWithScale: (CGFloat)  NS_DESIGNATED_INITIALIZER

Creates an image decoder.

Parameters
scaleImage's scale.
Returns
An image decoder.

◆ initWithScale: [3/4]

- (instancetype) initWithScale: (CGFloat)  NS_DESIGNATED_INITIALIZER

Creates an image decoder.

Parameters
scaleImage's scale.
Returns
An image decoder.

◆ initWithScale: [4/4]

- (instancetype) initWithScale: (CGFloat)  NS_DESIGNATED_INITIALIZER

Creates an image decoder.

Parameters
scaleImage's scale.
Returns
An image decoder.

◆ updateData:final: [1/4]

- (BOOL) updateData: (nullable NSData *)  data
final: (BOOL)  final 

Updates the incremental image with new data.

@discussion You can use this method to decode progressive/interlaced/baseline image when you do not have the complete image data. The data was retained by decoder, you should not modify the data in other thread during decoding.

Parameters
dataThe data to add to the image decoder. Each time you call this function, the 'data' parameter must contain all of the image file data accumulated so far.
finalA value that specifies whether the data is the final set. Pass YES if it is, NO otherwise. When the data is already finalized, you can not update the data anymore.
Returns
Whether succeed.

◆ updateData:final: [2/4]

- (BOOL) updateData: (nullable NSData *)  data
final: (BOOL)  final 

Updates the incremental image with new data.

@discussion You can use this method to decode progressive/interlaced/baseline image when you do not have the complete image data. The data was retained by decoder, you should not modify the data in other thread during decoding.

Parameters
dataThe data to add to the image decoder. Each time you call this function, the 'data' parameter must contain all of the image file data accumulated so far.
finalA value that specifies whether the data is the final set. Pass YES if it is, NO otherwise. When the data is already finalized, you can not update the data anymore.
Returns
Whether succeed.

◆ updateData:final: [3/4]

- (BOOL) updateData: (nullable NSData *)  data
final: (BOOL)  final 

Updates the incremental image with new data.

@discussion You can use this method to decode progressive/interlaced/baseline image when you do not have the complete image data. The data was retained by decoder, you should not modify the data in other thread during decoding.

Parameters
dataThe data to add to the image decoder. Each time you call this function, the 'data' parameter must contain all of the image file data accumulated so far.
finalA value that specifies whether the data is the final set. Pass YES if it is, NO otherwise. When the data is already finalized, you can not update the data anymore.
Returns
Whether succeed.

◆ updateData:final: [4/4]

- (BOOL) updateData: (nullable NSData *)  data
final: (BOOL)  final 

Updates the incremental image with new data.

@discussion You can use this method to decode progressive/interlaced/baseline image when you do not have the complete image data. The data was retained by decoder, you should not modify the data in other thread during decoding.

Parameters
dataThe data to add to the image decoder. Each time you call this function, the 'data' parameter must contain all of the image file data accumulated so far.
finalA value that specifies whether the data is the final set. Pass YES if it is, NO otherwise. When the data is already finalized, you can not update the data anymore.
Returns
Whether succeed.

Property Documentation

◆ data

- (NSData *) data
readnonatomicassign

Image data.

Definition at line 109 of file ThingEncryptImageCoder.h.

◆ finalized

- (BOOL) finalized
readnonatomicassign

Definition at line 116 of file ThingEncryptImageCoder.h.

◆ frameCount

- (NSUInteger) frameCount
readnonatomicassign

Image frame count.

Definition at line 112 of file ThingEncryptImageCoder.h.

◆ height

- (NSUInteger) height
readnonatomicassign

Image canvas height.

Definition at line 115 of file ThingEncryptImageCoder.h.

◆ loopCount

- (NSUInteger) loopCount
readnonatomicassign

Image loop count, 0 means infinite.

Definition at line 113 of file ThingEncryptImageCoder.h.

◆ scale

- (CGFloat) scale
readnonatomicassign

Image scale.

Definition at line 111 of file ThingEncryptImageCoder.h.

◆ type

- (ThingEncryptImageType) type
readnonatomicassign

Image data type.

Definition at line 110 of file ThingEncryptImageCoder.h.

◆ width

- (NSUInteger) width
readnonatomicassign

Image canvas width.

Definition at line 114 of file ThingEncryptImageCoder.h.


The documentation for this class was generated from the following files: