Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
The convenience method should use fitSize instead of targetSize.
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Oct 11, 2012
1 parent 3c15e72 commit 5d4338c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Source/FTPDFIconRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
targetColor:(UIColor *)targetColor;

+ (UIImage *)imageOfPDFNamed:(NSString *)pdfName
targetSize:(CGSize)targetSize;
fitSize:(CGSize)maxSize;
+ (UIImage *)imageOfPDFNamed:(NSString *)pdfName
targetSize:(CGSize)targetSize
fitSize:(CGSize)maxSize
targetColor:(UIColor *)targetColor
withIdentifier:(NSString *)identifier;

Expand All @@ -44,7 +44,7 @@
targetColor:(UIColor *)targetColor
withIdentifier:(NSString *)identifier;

- (void)fitSize:(CGSize)size;
- (void)fitSize:(CGSize)maxSize;
- (void)fitWidth:(CGFloat)targetWidth;
- (void)fitHeight:(CGFloat)targetHeight;

Expand Down
12 changes: 6 additions & 6 deletions Source/FTPDFIconRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ + (FTPDFIconRenderer *)iconRendererForPDFNamed:(NSString *)pdfName
}

+ (UIImage *)imageOfPDFNamed:(NSString *)pdfName
targetSize:(CGSize)targetSize
fitSize:(CGSize)maxSize
targetColor:(UIColor *)targetColor
withIdentifier:(NSString *)identifier;
{
FTPDFIconRenderer *renderer = [self iconRendererForPDFNamed:pdfName
targetColor:targetColor];
if (renderer) {
renderer.targetSize = targetSize;
[renderer fitSize:maxSize];
return [renderer imageWithCacheIdentifier:identifier];
}
return nil;
Expand Down Expand Up @@ -102,10 +102,10 @@ + (FTPDFIconRenderer *)iconRendererForPDFNamed:(NSString *)pdfName;
}

+ (UIImage *)imageOfPDFNamed:(NSString *)pdfName
targetSize:(CGSize)targetSize;
fitSize:(CGSize)maxSize
{
return [self imageOfPDFNamed:pdfName
targetSize:targetSize
fitSize:maxSize
targetColor:nil
withIdentifier:nil];
}
Expand Down Expand Up @@ -187,10 +187,10 @@ - (CGSize)targetSize;
return _targetSize;
}

- (void)fitSize:(CGSize)size;
- (void)fitSize:(CGSize)maxSize;
{
CGRect mediaRect = self.mediaRectOfSourcePage;
CGFloat scaleFactor = MAX(mediaRect.size.width / size.width, mediaRect.size.height / size.height);
CGFloat scaleFactor = MAX(mediaRect.size.width / maxSize.width, mediaRect.size.height / maxSize.height);
self.targetSize = CGSizeMake(ceilf(mediaRect.size.width / scaleFactor), ceilf(mediaRect.size.height / scaleFactor));
}

Expand Down

0 comments on commit 5d4338c

Please sign in to comment.