Skip to content

Commit

Permalink
Merge remote-tracking branch 'moredip/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBuckley committed Sep 24, 2013
2 parents 11f5163 + 10d0bd7 commit 5b8e830
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/UIImage+Frank.m
Expand Up @@ -19,13 +19,14 @@ + (UIImage *)imageFromApplication:(BOOL)allWindows resultInPortrait:(BOOL)result

UIInterfaceOrientation currentOrientation = application.statusBarOrientation;

CGFloat scale = [UIScreen mainScreen].scale;
CGSize size = [UIScreen mainScreen].bounds.size;

if (!resultInPortrait && UIInterfaceOrientationIsLandscape(currentOrientation)) {
size = CGSizeMake(size.height, size.width);
}

UIGraphicsBeginImageContext(size);
UIGraphicsBeginImageContextWithOptions(size, NO, scale);
CGContextRef context = UIGraphicsGetCurrentContext();

if (!resultInPortrait) {
Expand Down Expand Up @@ -54,7 +55,7 @@ + (UIImage *)imageFromApplication:(BOOL)allWindows resultInPortrait:(BOOL)result
- window.bounds.size.width * window.layer.anchorPoint.x,
- window.bounds.size.height * window.layer.anchorPoint.y);

[window.layer renderInContext:UIGraphicsGetCurrentContext()];
[window.layer.presentationLayer renderInContext:UIGraphicsGetCurrentContext()];

CGContextRestoreGState(context);
}
Expand All @@ -65,18 +66,16 @@ + (UIImage *)imageFromApplication:(BOOL)allWindows resultInPortrait:(BOOL)result
return image;
}

- (UIImage *)imageCropedToFrame:(CGRect)cropFrame
{
- (UIImage *)imageCropedToFrame:(CGRect)cropFrame {
CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], cropFrame);
UIImage *result = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
return result;
}

- (UIImage *)imageMaskedAtFrame:(CGRect)maskFrame
{
- (UIImage *)imageMaskedAtFrame:(CGRect)maskFrame {
CGRect imageFrame = CGRectMake(0, 0, self.size.width, self.size.height);
UIGraphicsBeginImageContext(self.size);
UIGraphicsBeginImageContextWithOptions(self.size, NO, self.scale);
[self drawInRect:imageFrame];

[[UIColor blackColor] set];
Expand Down
5 changes: 4 additions & 1 deletion src/UIView+ImageCapture.m
Expand Up @@ -12,7 +12,10 @@
@implementation UIView (ImageCapture)

- (UIImage *)captureImage {
UIGraphicsBeginImageContext(self.bounds.size);
CGFloat scale = [UIScreen mainScreen].scale;
CGSize size = self.bounds.size;

UIGraphicsBeginImageContextWithOptions(size, NO, scale);

[self.layer renderInContext:UIGraphicsGetCurrentContext()];

Expand Down

0 comments on commit 5b8e830

Please sign in to comment.