DSImageData
The DSImageData
class defines the structure of an object that represents an image.
Definition
Assembly: DynamsoftCore.xcframework
- Objective-C
- Swift
@interface DSImageData : NSObject
class ImageData : NSObject
Methods & Attributes
Attributes | Type | Description |
---|---|---|
bytes |
NSData * | The image data content in a byte array. |
width |
NSInteger | The width of the image in pixels. |
height |
NSInteger | The height of the image in pixels. |
stride |
NSInteger | The stride (or scan width) of the image. |
format |
DSImagePixelFormat | The image pixel format used in the image byte array. |
orientation |
NSInteger | The orientation information of the image. The library is able to read the orientation information from the EXIF data of the image file. |
tag |
DSImageTag * | The tag of the image. |
Method | Description |
---|---|
toUIImage |
Transform the DSImageData to a UIImage. |
bytes
The image data content in a byte array.
- Objective-C
- Swift
@property(nonatomic, copy) NSData *bytes;
var bytes: Data? { get set }
width
The width of the image in pixels.
- Objective-C
- Swift
@property (nonatomic, assign) NSInteger width
var width: Int { get set }
height
The height of the image in pixels.
- Objective-C
- Swift
@property (nonatomic, assign) NSInteger height
var height: Int { get set }
stride
The stride (or scan width) of the image.
- Objective-C
- Swift
@property (nonatomic, assign) NSInteger stride
var stride: Int { get set }
format
The image pixel format used in the image byte array.
- Objective-C
- Swift
@property (nonatomic, assign) DSImagePixelFormat format
var format: DSImagePixelFormat { get set }
orientation
The orientation information of the image. The library is able to read the orientation information from the EXIF data of the image file.
- Objective-C
- Swift
@property (nonatomic, assign) NSInteger orientation
var orientation: Int { get set }
tag
The tag of the image.
- Objective-C
- Swift
@property(nonatomic, strong, nullable) DSImageTag *tag;
var tag?: DSImageTag { get set }
toUIImage
Transform the DSImageData to a UIImage.
- Objective-C
- Swift
- (UIImage * _Nullable)toUIImage:(NSError *_Nullable *_Nullable)error;
func toUIImage() throws -> UIImage
Parameters
error
: An NSError
pointer. If an error occurs, it will represent the error information.
Error
Error Code | Value | Description |
---|---|---|
EC_BPP_NOT_SUPPORTED | -10007 | The pixel format is not supported or the ImageData is invalid. |
Return Value
A UIImage
that converted from the DSImageData
.
Code Snippet
- Objective-C
- Swift
NSError *error; UIImage *image = [imageData toUIImage:&error];
do{ image = try imageData.toUIImage() } catch{ // Add your code to deal with exceptions. }