EMImageMessageBody.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*!
  2. * \~chinese
  3. * @header EMImageMessageBody.h
  4. * @abstract 图片消息体
  5. * @author Hyphenate
  6. * @version 3.00
  7. *
  8. * \~english
  9. * @header EMImageMessageBody.h
  10. * @abstract Image message body
  11. * @author Hyphenate
  12. * @version 3.00
  13. */
  14. #import <Foundation/Foundation.h>
  15. #import "EMFileMessageBody.h"
  16. /*!
  17. * \~chinese
  18. * 通过创建的消息体的图片
  19. * -(instancetype)initWithData:displayName:
  20. * or
  21. * -(instancetype)initWithData:thumbnailData:
  22. * Note: 图片消息体,SDK会根据压缩率compressRatio來发送消息
  23. *
  24. * \~english
  25. * Image message body
  26. * -(instancetype)initWithData:displayName:
  27. * or
  28. * -(instancetype)initWithData:thumbnailData:
  29. * Note: SDK will compress the image based on the attribute compressRatio when delivering the image
  30. */
  31. @interface EMImageMessageBody : EMFileMessageBody
  32. /*!
  33. * \~chinese
  34. * 图片附件的尺寸
  35. *
  36. * \~english
  37. * Resolution of the image
  38. */
  39. @property (nonatomic) CGSize size;
  40. /*!
  41. * \~chinese
  42. * SDK会根据压缩率compressRatio來发送消息
  43. * 设置发送图片消息时的压缩率。1.0表示发送原图不压缩。默认值是0.6,压缩的倍数是0.6倍。如果设置了小于等于0的值,则使用默认值
  44. *
  45. * \~english
  46. * SDK will compress the image based on the attribute compressRatio when delivering the image
  47. * Image compression ratio. 1.0x is original image without compression , default value is 0.6x (60% compression). SDK uses the default value if the given value is less than zero.
  48. */
  49. @property (nonatomic) CGFloat compressionRatio;
  50. /*!
  51. * \~chinese
  52. * 缩略图的显示名
  53. *
  54. * \~english
  55. * Display name of thumbnail
  56. */
  57. @property (nonatomic, copy) NSString *thumbnailDisplayName;
  58. /*!
  59. * \~chinese
  60. * 缩略图的本地路径
  61. * UIImage *image = [UIImage imageWithContentsOfFile:thumbnailLocalPath];
  62. *
  63. * \~english
  64. * Local path of thumbnail
  65. * UIImage *image = [UIImage imageWithContentsOfFile:thumbnailLocalPath];
  66. */
  67. @property (nonatomic, copy) NSString *thumbnailLocalPath;
  68. /*!
  69. * \~chinese
  70. * 缩略图在服务器的路径
  71. *
  72. * \~english
  73. * Server url path of thumbnail
  74. */
  75. @property (nonatomic, copy) NSString *thumbnailRemotePath;
  76. /*!
  77. * \~chinese
  78. * 缩略图的密钥, 下载缩略图时需要密匙做校验
  79. *
  80. * \~english
  81. * Secret key for downloading thumbnail image
  82. */
  83. @property (nonatomic, copy) NSString *thumbnailSecretKey;
  84. /*!
  85. * \~chinese
  86. * 缩略图的尺寸
  87. *
  88. * \~english
  89. * Resolution of the thumbnail
  90. */
  91. @property (nonatomic) CGSize thumbnailSize;
  92. /*!
  93. * \~chinese
  94. * 缩略图文件的大小, 以字节为单位
  95. *
  96. * \~english
  97. * File length of a thumbnail, in bytes
  98. */
  99. @property (nonatomic) long long thumbnailFileLength;
  100. /*!
  101. * \~chinese
  102. * 缩略图下载状态
  103. *
  104. * \~english
  105. * Download status of a thumbnail
  106. */
  107. @property (nonatomic)EMDownloadStatus thumbnailDownloadStatus;
  108. /*!
  109. * \~chinese
  110. * 初始化图片消息体
  111. * 接收方的Thumbnail是服务器根据发送方的aData生成,生成大小可以在console的
  112. * "Thumbnail Size" 配置,配置时有两个参数,分别是width和height,单位是px。为等比缩放,举例如下:
  113. *
  114. * aData的分别率为 200 x 400 (1:2), 配置的width,height为 200 x 200,则生成的缩略图为 100 x 200
  115. * aData的分别率为 600 x 300 (2:1), 配置的width,height为 200 x 200,则生成的缩略图为 200 x 100
  116. *
  117. * 发送方可以通过 thumbnailLocalPath 得到缩略图。
  118. * 接受消息时,接收方会自动根据thumbnailRemotePath下载缩略图,存储到本地,下载失败还可以通过方法
  119. * downloadMessageThumbnail:progress:completion:
  120. *
  121. * @param aData 图片数据
  122. * @param aThumbnailData 缩略图数据。不会上传到服务器,只是用于本地展示使用。
  123. *
  124. * @result 图片消息体实例
  125. *
  126. * \~english
  127. * Initialize an image message body instance
  128. *
  129. * Image receiver will receive object thumbnail that generated based on sender's aData object.
  130. * Adjust thumbnail resolution on Hyphenate conosle -> "Thumbnail Size" -> width and height. Unit in px.
  131. * ex. aData resolution 200 x 400 (1:2), thumbnail resolution setting (width x height) 200 x 200, then will generate thumbnail in 100 x 200
  132. * ex. aData resolution 600 x 300 (2:1), thumbnail resolution setting (width x height) 200 x 200, then will generate thumbnail in 200 x 100
  133. *
  134. * Image sender can obtain thumbnail from thumbnailLocalPath
  135. * Image receiver will get thumbnail stored under thumbnailRemotePath after a successful download automatically.
  136. * However, if the automatic downloading failed, use the following method,
  137. * downloadMessageThumbnail:progress:completion:
  138. *
  139. * @param aData original image object in NSData format
  140. * @param aThumbnailData Thumbnail in NSData format. Will not push to server, but only for local usage
  141. *
  142. * @result An image message body instance
  143. */
  144. - (instancetype)initWithData:(NSData *)aData
  145. thumbnailData:(NSData *)aThumbnailData;
  146. #pragma mark - EM_DEPRECATED_IOS < 3.2.3
  147. /*!
  148. * \~chinese
  149. * 设置发送图片消息时的压缩率,1.0时不压缩,默认值是0.6,如果设置了小于等于0的值,则使用默认值
  150. *
  151. * \~english
  152. * Image compression ratio. 1.0 without compression, default value is 0.6. SDK uses the default value if the given value is less than zero.
  153. */
  154. @property (nonatomic) CGFloat compressRatio __deprecated_msg("Use - compressionRatio");
  155. @end