JLChen
2021-05-18 a869383e163a18cdedcf587383c1eca043129754
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
//
//  Copyright © 2015年 Anson. All rights reserved.
//
 
#import <UIKit/UIKit.h>
#import <Accelerate/Accelerate.h>
#import <QuartzCore/QuartzCore.h>
#import <Availability.h>
 
@interface UIImage (LeChange)
 
//图片宽度
@property(nonatomic, assign, readonly) CGFloat width;
 
//图片高度
@property(nonatomic, assign, readonly) CGFloat height;
 
/*!
 *  @author peng_kongan, 15-12-10 14:12:02
 *
 *  @brief  毛玻璃效果
 *
 *  @param blur 效果级别  最小为0 最大为1
 *
 *  @return 毛玻璃化后的图片
 */
- (UIImage *)lc_imageWithBlurLevel:(CGFloat)blur;
 
/*!
 *  @author peng_kongan, 16-01-15 09:01:30
 *
 *  @brief  将图片存到本地
 *
 *  @param aPath 本地路径
 *
 *  @return 操作结果
 */
- (BOOL)lc_writeToFileAtPath:(NSString*)aPath;
 
/*!
 *  @author peng_kongan, 15-12-12 13:12:00
 *
 *  @brief  获取屏幕截图
 *
 *  @return 屏幕截图
 */
+ (UIImage *)lc_imageWithScreenContents;
 
 
 
/*!
 *  @author peng_kongan, 15-12-12 13:12:11
 *
 *  @brief  根据颜色创建图片
 *
 *  @param color 颜色
 *
 *  @return UIImage
 */
+ (UIImage *)lc_createImageWithColor:(UIColor *)color;
 
/*!
 *  @author peng_kongan, 15-12-12 13:12:21
 *
 *  @brief  获取图片模块区域的图
 *
 *  @param rect 区域
 *
 *  @return 截取后的图片
 */
-(UIImage *)lc_imageAtRect:(CGRect)rect;
 
/*!
 *  @author peng_kongan, 15-12-12 13:12:08
 *
 *  @brief  //成比例的缩小图片
 *
 *  @param targetSize <#targetSize description#>
 *
 *  @return <#return value description#>
 */
- (UIImage *)lc_imageByScalingProportionallyToMinimumSize:(CGSize)targetSize;
 
/*!
 *  @author peng_kongan, 15-12-12 13:12:30
 *
 *  @brief  //成比例的缩放图片
 *
 *  @param targetSize <#targetSize description#>
 *
 *  @return <#return value description#>
 */
- (UIImage *)lc_imageByScalingProportionallyToSize:(CGSize)targetSize;
 
/*!
 *  @author peng_kongan, 15-12-12 13:12:15
 *
 *  @brief  拉伸图片到指定大小
 *
 *  @param targetSize <#targetSize description#>
 *
 *  @return <#return value description#>
 */
- (UIImage *)lc_imageByScalingToSize:(CGSize)targetSize;
 
/*!
 *  @author peng_kongan, 15-12-12 13:12:26
 *
 *  @brief  按弧度旋转
 *
 *  @param radians <#radians description#>
 *
 *  @return <#return value description#>
 */
- (UIImage *)lc_imageRotatedByRadians:(CGFloat)radians;
 
/*!
 *  @author peng_kongan, 15-12-12 13:12:35
 *
 *  @brief  按角度旋转
 *
 *  @param degrees <#degrees description#>
 *
 *  @return <#return value description#>
 */
- (UIImage *)lc_imageRotatedByDegrees:(CGFloat)degrees;  //按角都旋转
 
/*!
 *  @author peng_kongan, 15-12-12 13:12:50
 *
 *  @brief  根据宽度 按比例缩放图片
 *
 *  @param newWidth 心的宽度
 *
 *  @return <#return value description#>
 */
- (UIImage *)lc_keepScaleWithWidth:(float) newWidth;     //根据宽度 按比例缩放图片
 
/*!
 *  @author peng_kongan, 15-12-12 13:12:07
 *
 *  @brief  无损拉伸  适用于IOS5.0以上
 *
 *  @param top    上边距
 *  @param left   左边距
 *  @param bottom 下边距
 *  @param right  右边距
 *
 *  @return 拉伸后的图
 */
- (UIImage *)lc_scaleWithOutDamageInTop:(CGFloat)top     //无损拉伸  试用于ios5.0
                                left:(CGFloat)left
                              bottom:(CGFloat)bottom
                               right:(CGFloat)right;
 
/**
 *  图片缩放
 *
 *  @param scaleSize 缩放比例
 *
 *  @return 缩放后图片
 */
- (UIImage *)lc_chnageToScale:(float)scaleSize;
 
/**
 *  中心区域裁剪成方形图片
 *
 *  @param size 目标尺寸,不自动进行放大,实际可能比size要小
 *
 *  @return 裁剪后的图片
 */
- (UIImage *)lc_centerClipBySize:(CGFloat)size;
 
/**
 *  中心区域裁剪成方形图片
 *
 *  @param size 目标尺寸,不自动进行放大,实际可能比size要小
 *
 *  @return 裁剪后的图片
 */
- (UIImage *)lc_centerScaleToSize:(CGSize)size;
 
/**
 *  裁剪中心区域固定比例的最大图片
 *
 *  @param rate 裁剪图片比例,比例大于1
 *
 *  @return 裁剪后的图片
 */
- (UIImage *)lc_cutWithWideRate:(CGFloat)rate;
 
/**
 拉伸图片到指定大小
 
 @param size 制定大小
 @return 新图片
 */
- (UIImage *)lc_imageScalingWithSize:(CGSize)size;
 
- (UIImage *)lc_imageWithColor:(UIColor *)color;
 
/**
 *  压缩图片到指定文件大小
 *
 *  @param size  目标大小(最大值)
 *
 *  @return 返回的图片文件
 */
- (NSData *)compressToMaxDataSizeKBytes:(CGFloat)size;
 
@end