Skip to content

Commit

Permalink
Add minimum image output size property and implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvkon committed May 22, 2015
1 parent a5709d2 commit e590f8a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions RSKImageCropper/RSKImageCropViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ typedef NS_ENUM(NSUInteger, RSKImageCropMode) {
*/
@property (assign, getter=isRotationEnabled, nonatomic) BOOL rotationEnabled;

// Added by https://github.com/Arvkon
- (void)setMinOutputSize:(CGSize)minSize;

/// -------------------------------
/// @name Accessing the UI Elements
/// -------------------------------
Expand Down
6 changes: 6 additions & 0 deletions RSKImageCropper/RSKImageCropViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,12 @@ - (void)setRotationAngle:(CGFloat)rotationAngle
}
}

// Added by https://github.com/Arvkon
- (void)setMinOutputSize:(CGSize)minSize
{
self.imageScrollView.minOutputSize = minSize;
}

#pragma mark - Action handling

- (void)onCancelButtonTouch:(UIBarButtonItem *)sender
Expand Down
3 changes: 3 additions & 0 deletions RSKImageCropper/RSKImageScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
@property (nonatomic, strong) UIImageView *zoomView;
@property (nonatomic, assign) BOOL aspectFill;

// Added by https://github.com/Arvkon
@property (nonatomic, assign) CGSize minOutputSize;

- (void)displayImage:(UIImage *)image;

@end
9 changes: 8 additions & 1 deletion RSKImageCropper/RSKImageScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,14 @@ - (void)setMaxMinZoomScalesForCurrentBounds
if (minScale > maxScale) {
minScale = maxScale;
}


// Added by https://github.com/Arvkon
if (boundsSize.width < boundsSize.height) {
maxScale = MIN(maxScale, boundsSize.width / self.minOutputSize.width);
} else {
maxScale = MIN(maxScale, boundsSize.height / self.minOutputSize.height);
}

self.maximumZoomScale = maxScale;
self.minimumZoomScale = minScale;
}
Expand Down

0 comments on commit e590f8a

Please sign in to comment.