HyphenateChatSDK 4.5.0
构造函数 | 属性 | 所有成员列表
EMImageMessageBody类 参考

#import <EMImageMessageBody.h>

类 EMImageMessageBody 继承关系图:
EMFileMessageBody EMMessageBody

构造函数

(instancetype) - initWithData:thumbnailData:
 
- 构造函数 继承自 EMFileMessageBody
(instancetype _Nonnull) - initWithLocalPath:displayName:
 
(instancetype _Nonnull) - initWithData:displayName:
 

属性

CGSize size
 
CGFloat compressionRatio
 
NSString * thumbnailDisplayName
 
NSString * thumbnailLocalPath
 
NSString * thumbnailRemotePath
 
NSString * thumbnailSecretKey
 
CGSize thumbnailSize
 
long long thumbnailFileLength
 
EMDownloadStatus thumbnailDownloadStatus
 
- 属性 继承自 EMFileMessageBody
NSString * displayName
 
NSString * localPath
 
NSString * remotePath
 
NSString * secretKey
 
long long fileLength
 
EMDownloadStatus downloadStatus
 
- 属性 继承自 EMMessageBody
EMMessageBodyType type
 
NSUInteger operationTime
 
NSString * operatorId
 
NSUInteger operatorCount
 

详细描述

@header EMImageMessageBody.h @abstract 图片消息体类

作者
Hyphenate
版本
3.00

创建的图片消息体。以下为两种图片消息体生成的方式,图片数据和图片显示名称或者图片内容和缩略图数据。 -(instancetype)initWithData:displayName: or -(instancetype)initWithData:thumbnailData: Note: 图片消息体,SDK 会根据压缩率 compressRatio 來发送消息。

函数文档

◆ initWithData:thumbnailData:

- (instancetype) initWithData: (NSData *)  aData
thumbnailData: (NSData *)  aThumbnailData 

初始化图片消息体。

参数
aData图片数据。如果该图片的分辨率和你在控制台 Thumbnail Size 中配置的 width 和 height 不一致,SDK 会对该图片进行压缩。压缩原则维持图片的宽高比,是在控制台 width 和 height 的值为缩略图宽高中的更大值,然后按宽高比计算另一个值。以控制台中配置的 width 和 height 为 200 x 200 为例:

如果 aData 的分辨率为 200 x 400 (1:2),则生成的缩略图分辨率为 100 x 200。 如果 aData 的分辨率为 600 x 300 (2:1),则生成的缩略图分辨率为 200 x 100。

参数
aThumbnailData缩略图数据。该参数不会上传到服务器,只用于本地展示。

@Result 图片消息体实例。

属性说明

◆ compressionRatio

- (CGFloat) compressionRatio
readwritenonatomicassign

图片消息文件的压缩率。

SDK 在发送图片消息时,会根据该参数的值来压缩图片文件。取值范围是 (0.0,1.0],默认值是 0.6。其中 1.0 表示原图文件不压缩,0.6 表示将原图文件大小压缩为初始文件的 0.6 倍。如果设置小于等于 0,则 SDK 使用默认值。

◆ size

- (CGSize) size
readwritenonatomicassign

图片附件的尺寸。

◆ thumbnailDisplayName

- (NSString*) thumbnailDisplayName
readwritenonatomiccopy

缩略图的显示名。

◆ thumbnailDownloadStatus

- (EMDownloadStatus) thumbnailDownloadStatus
readwritenonatomicassign

缩略图下载状态。

◆ thumbnailFileLength

- (long long) thumbnailFileLength
readwritenonatomicassign

缩略图文件的大小, 以字节为单位。

◆ thumbnailLocalPath

- (NSString*) thumbnailLocalPath
readwritenonatomiccopy

缩略图的本地路径。发送方可以根据该属性获取缩略本地路径。调用 imageWithContentsOfFile 方法,传入 thumbnailLocalPath 即可获取缩略图的数据。

UIImage *image = [UIImage imageWithContentsOfFile:thumbnailLocalPath];

◆ thumbnailRemotePath

- (NSString*) thumbnailRemotePath
readwritenonatomiccopy

缩略图在服务器的路径。接收方可以通过该属性获取缩略图服务器路径。

◆ thumbnailSecretKey

- (NSString*) thumbnailSecretKey
readwritenonatomiccopy

缩略图的密钥。下载缩略图时用户需要提供密钥进行校验。

◆ thumbnailSize

- (CGSize) thumbnailSize
readwritenonatomicassign

缩略图的尺寸。


该类的文档由以下文件生成: