Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill padding color of cropped image with background color of view #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ImageEditor/HFImageEditorViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ typedef void(^HFImageEditorDoneCallback)(UIImage *image, BOOL canceled);
@property(nonatomic,assign) CGFloat outputWidth;
@property(nonatomic,assign) CGFloat minimumScale;
@property(nonatomic,assign) CGFloat maximumScale;
@property(nonatomic,assign) CGColorRef outputBackgroundColor;

@property(nonatomic,assign) BOOL panEnabled;
@property(nonatomic,assign) BOOL rotateEnabled;
Expand Down
3 changes: 2 additions & 1 deletion ImageEditor/HFImageEditorViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ - (void)commonInit
self.panEnabled = YES;
self.scaleEnabled = YES;
self.rotateEnabled = YES;
self.outputBackgroundColor = [[UIColor clearColor] CGColor];
}

////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -610,7 +611,7 @@ - (CGImageRef)newTransformedImage:(CGAffineTransform)transform
0,
CGImageGetColorSpace(source),
CGImageGetBitmapInfo(source));
CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
CGContextSetFillColorWithColor(context, self.outputBackgroundColor);
CGContextFillRect(context, CGRectMake(0, 0, outputSize.width, outputSize.height));

CGAffineTransform uiCoords = CGAffineTransformMakeScale(outputSize.width/cropRect.size.width,
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ The width of the cropped image. If not defined, the width of the source image is
The bounds for image scaling. If not defined, image zoom is unlimited.

#### checkBounds
Set to true to bound the image transform so that you dont' get a black backround on the resulting image.
Set to true to bound the image transform so that you dont' get a backround on the resulting image.

#### outputBackgroundColor
The color used to fill a background of the resulting image if checkBounds property is set to false and a margin exists.

#### panEnabled, rotateEnabled, scaleEnabled, tapToResetEnabled
BOOL property to enable/disable specific gestures
Expand Down