Skip to content

Commit 865d46f

Browse files
author
yuzheng.tz
committed
新增notScaleImage属性,设置为YES时内部不去缩放图片
1 parent 557bb3d commit 865d46f

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

TZImagePickerController/TZImagePickerController/TZImageManager.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,9 @@ - (int32_t)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion
553553
options.resizeMode = PHImageRequestOptionsResizeModeFast;
554554
[[PHImageManager defaultManager] requestImageDataForAsset:asset options:options resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
555555
UIImage *resultImage = [UIImage imageWithData:imageData scale:0.1];
556-
resultImage = [self scaleImage:resultImage toSize:imageSize];
556+
if (![TZImagePickerConfig sharedInstance].notScaleImage) {
557+
resultImage = [self scaleImage:resultImage toSize:imageSize];
558+
}
557559
if (!resultImage) {
558560
resultImage = image;
559561
}

TZImagePickerController/TZImagePickerController/TZImagePickerController.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@
132132
/// Default is white color with 0.8 alpha;
133133
@property (strong, nonatomic) UIColor *cannotSelectLayerColor;
134134

135+
/// Default is No, if set YES, the result photo will not be scaled to photoWidth pixel width. The photoWidth default is 828px
136+
/// 默认是NO,如果设置为YES,内部不会缩放图片到photoWidth像素宽
137+
@property (assign, nonatomic) BOOL notScaleImage;
138+
135139
/// The photos user have selected
136140
/// 用户选中过的图片数组
137141
@property (nonatomic, strong) NSMutableArray *selectedAssets;
@@ -330,4 +334,5 @@
330334
@property (assign, nonatomic) NSInteger gifPreviewMaxImagesCount;
331335
@property (assign, nonatomic) BOOL showSelectedIndex;
332336
@property (assign, nonatomic) BOOL showPhotoCannotSelectLayer;
337+
@property (assign, nonatomic) BOOL notScaleImage;
333338
@end

TZImagePickerController/TZImagePickerController/TZImagePickerController.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ - (void)configDefaultSetting {
271271
self.barItemTextFont = [UIFont systemFontOfSize:15];
272272
self.barItemTextColor = [UIColor whiteColor];
273273
self.allowPreview = YES;
274+
self.notScaleImage = NO;
274275
self.statusBarStyle = UIStatusBarStyleLightContent;
275276
self.cannotSelectLayerColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8];
276277
self.allowCameraLocation = YES;
@@ -354,6 +355,11 @@ - (void)setShowPhotoCannotSelectLayer:(BOOL)showPhotoCannotSelectLayer {
354355
[TZImagePickerConfig sharedInstance].showPhotoCannotSelectLayer = showPhotoCannotSelectLayer;
355356
}
356357

358+
- (void)setNotScaleImage:(BOOL)notScaleImage {
359+
_notScaleImage = notScaleImage;
360+
[TZImagePickerConfig sharedInstance].notScaleImage = notScaleImage;
361+
}
362+
357363
- (void)observeAuthrizationStatusChange {
358364
[_timer invalidate];
359365
_timer = nil;

TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,9 @@ - (void)doneButtonClick {
386386
[[TZImageManager manager] getPhotoWithAsset:model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
387387
if (isDegraded) return;
388388
if (photo) {
389-
photo = [[TZImageManager manager] scaleImage:photo toSize:CGSizeMake(tzImagePickerVc.photoWidth, (int)(tzImagePickerVc.photoWidth * photo.size.height / photo.size.width))];
389+
if (![TZImagePickerConfig sharedInstance].notScaleImage) {
390+
photo = [[TZImageManager manager] scaleImage:photo toSize:CGSizeMake(tzImagePickerVc.photoWidth, (int)(tzImagePickerVc.photoWidth * photo.size.height / photo.size.width))];
391+
}
390392
[photos replaceObjectAtIndex:i withObject:photo];
391393
}
392394
if (info) [infoArr replaceObjectAtIndex:i withObject:info];

0 commit comments

Comments
 (0)