Skip to content

Commit 48074cd

Browse files
committed
Update the readme about the bitmap form of SVG
1 parent f59220e commit 48074cd

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ let package = Package(
6666

6767
## Usage
6868

69-
### Use UIImageView
69+
### Render SVG as vector image
7070

7171
To use SVG coder, you should firstly add the `SDImageSVGCoder` to the coders manager. Then you can call the View Category method to start load SVG images. See [Wiki - Coder Usage](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#coder-usage) here for these steps.
7272

@@ -106,10 +106,34 @@ imageView.frame = rect
106106

107107
Note since UIImageView/NSImageView support this vector rendering, it means this coder plugin can be compatible for [SwiftUI](https://developer.apple.com/xcode/swiftui/). Check [SDWebImageSwiftUI](https://github.com/SDWebImage/SDWebImageSwiftUI/issues/50) for usage.
108108

109+
## Render SVG as bitmap image
110+
111+
In most cases, vector SVG is preferred. But however, sometimes you may want the bitmap form of SVG, used for image processing. You can use `.svgPrefersBitmap` to provide the bitmap format as well.
112+
113+
By default it use the SVG canvas size. You can also specify a desired size during image loading using `.svgImageSize` context option. And you can specify whether or not to keep aspect ratio during scale using `.pdfImagePreserveAspectRatio` context option.
114+
115+
+ Objective-C
116+
117+
```objectivec
118+
UIImageView *imageView;
119+
CGSize SVGImageSize = CGSizeMake(500, 500);
120+
[imageView sd_setImageWithURL:url placeholderImage:nil options:0 context:@{SDWebImageContextSVGImageSize : @(SVGImageSize)];
121+
```
122+
123+
+ Swift
124+
125+
```swift
126+
let imageView: UIImageView
127+
let SVGImageSize = CGSize(width: 500, height: 500)
128+
imageView.sd_setImage(with: url, placeholderImage: nil, options: [], context: [.SVGImageSize : SVGImageSize])
129+
```
130+
109131
## Export SVG data
110132

111133
`SDWebImageSVGCoder` provide an easy way to export the SVG image generated by this coder plugin, to the original SVG data.
112134

135+
Note: The bitmap form of SVG does not support SVG data export.
136+
113137
+ Objective-C
114138

115139
```objectivec

0 commit comments

Comments
 (0)