Skip to content

Commit 2dae0f4

Browse files
committed
Fix that sd_imageFormat was not set. Update some comments
1 parent 8c07731 commit 2dae0f4

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ imageView.sd_setImage(with: url)
7474

7575
For firmware which is below iOS/tvOS 11+, `UIImage` && `UIImageView` does not support vector image rendering. Even you can add PDF image in Xcode Asset Catalog, it was encoded to bitmap PNG format when compiled but not support runtime scale.
7676

77-
For `UIImageView`, we will only parse PDF with a fixed image size (from the PDF cropBox information). But we also support you to specify a desired size during image loading using `PDFImageSize` context option. And you can specify whether to keep aspect ratio using `PDFImagePreserveAspectRatio` context option.
77+
For `UIImageView`, we will only parse PDF with a fixed image size (from the PDF cropBox information). But we also support you to specify a desired size during image loading using `PDFImageSize` context option. And you can specify whether or not to keep aspect ratio during scale using `PDFImagePreserveAspectRatio` context option.
7878

7979
+ Objective-C
8080

SDWebImagePDFCoder/Classes/SDImagePDFCoder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
NS_ASSUME_NONNULL_BEGIN
1111

1212
/***
13-
SDImagePDFCoder is a PDF image coder, which use the built-in UIKit/AppKit method to decode PDF images. And it will use the Core Graphics to draw PDF images when needed (For example, current firmware does not support built-in rendering). This class does not use PDFKit framwork (iOS11+/macOS 10.4+).
13+
SDImagePDFCoder is a PDF image coder, which use the built-in UIKit/AppKit method to decode PDF images. And it will use the Core Graphics to draw PDF images when needed (For example, current firmware does not support built-in rendering). This class does not use PDFKit framwork because we focus on PDF vector images but not document pages rendering.
1414
15-
@note: For iOS/tvOS, from iOS/tvOS 11+, Apple support built-in vector scale for PDF image in `UIImage`. Which means you can just get set a image to the `UIImaegView`, then changing image view's bounds, contentMode to adjust the PDF image without losing any detail. However, when running on lower firmware, we don't support vector scaling and parse PDF image as a bitmap image. You can use `SDWebImageContextPDFImageSize` or `SDWebImageContextPDFImagePreserveAspectRatio` during loading to specify a desired size and aspect ratio.
15+
@note: For iOS/tvOS, from iOS/tvOS 11+, Apple support built-in vector scale for PDF image in `UIImage`. Which means you can just get set a image to the `UIImaegView`, then changing image view's bounds, contentMode to adjust the PDF image without losing any detail. However, when running on lower firmware, we don't support vector scaling and parse PDF image as a bitmap image. You can use `SDWebImageContextPDFImageSize` and `SDWebImageContextPDFImagePreserveAspectRatio` during image loading to specify a desired size (such as larger size for view rendering).
1616
@note: For macOS, Apple support built-in vector scale for PDF image in `NSImage`. However, `NSImage` is mutable, you can change the size after image was loaded.
17-
@note: By default we parse the first page (pageNumber = 1) of PDF image, for custom page number, use `SDWebImageContextPDFPageNumber`.
17+
@note: By default we parse the first page (pageNumber = 1) of PDF image, for custom page number, check `SDWebImageContextPDFPageNumber` context option.
1818
*/
1919

2020
static const SDImageFormat SDImageFormatPDF = 13;

SDWebImagePDFCoder/Classes/SDImagePDFCoder.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ - (UIImage *)sd_createPDFImageWithData:(nonnull NSData *)data pageNumber:(NSUInt
158158
CGPDFDocumentRelease(document);
159159
#endif
160160

161+
image.sd_imageFormat = SDImageFormatPDF;
162+
161163
return image;
162164
}
163165

SDWebImagePDFCoder/Classes/SDWebImagePDFCoderDefine.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextPDFPag
1818
/**
1919
A CGSize raw value which specify the desired PDF image size during image loading. Because vector image like PDF format, may not contains a fixed size, or you want to get a larger size bitmap representation UIImage. (NSValue)
2020
If you don't provide this value, use the PDF cropBox size instead.
21-
@note For iOS 11+, you don't need this options at all. Because UIImage support built-in vector rendering and scaling for PDF. Changing `UIImageView.bounds` instead.
22-
@note For macOS user. Changing the `NSImageView.bounds` instead.
21+
@note For iOS/tvOS 11+, you don't need this option and it will be ignored. Because UIImage support built-in vector rendering and scaling for PDF. Changing imageView's contentMode and bounds instead.
22+
@note For macOS user. Changing imageViews' imageScaling and bounds instead.
2323
*/
2424
FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextPDFImageSize;
2525

2626
/**
2727
A BOOL value which specify the whether PDF image should keep aspect ratio during image loading. Because when you specify image size via `SDWebImageContextPDFImageSize`, we need to know whether to keep aspect ratio or not when image size is not equal to PDF cropBox size. (NSNumber)
2828
If you don't provide this value, use YES for default value.
29-
@note For iOS 11+, you don't need this options at all. Because UIImage support built-in vector rendering and scaling for PDF. Changing `UIImageView.contentMode` instead.
30-
@note For macOS user. Changing `NSImage.imageScaling` instead.
29+
@note For iOS/tvOS 11+, you don't need this option and it will be ignored. Because UIImage support built-in vector rendering and scaling for PDF. Changing imageView's contentMode and bounds instead.
30+
@note For macOS user. Changing imageViews' imageScaling and bounds instead.
3131
*/
3232
FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextPDFImagePreserveAspectRatio;
3333

0 commit comments

Comments
 (0)