https://github.com/sdwebimage/sdwebimagebpgcoder
A BPG coder plugin for SDWebImage, use libbpg
https://github.com/sdwebimage/sdwebimagebpgcoder
bpg cocoapods ios macos objective-c sdwebimage
Last synced: 18 days ago
JSON representation
A BPG coder plugin for SDWebImage, use libbpg
- Host: GitHub
- URL: https://github.com/sdwebimage/sdwebimagebpgcoder
- Owner: SDWebImage
- License: mit
- Created: 2017-10-26T04:45:27.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-06-14T08:50:10.000Z (about 2 years ago)
- Last Synced: 2025-06-04T03:28:24.795Z (24 days ago)
- Topics: bpg, cocoapods, ios, macos, objective-c, sdwebimage
- Language: C
- Homepage:
- Size: 35 MB
- Stars: 11
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SDWebImageBPGCoder
[](https://travis-ci.org/SDWebImage/SDWebImageBPGCoder)
[](http://cocoapods.org/pods/SDWebImageBPGCoder)
[](http://cocoapods.org/pods/SDWebImageBPGCoder)
[](http://cocoapods.org/pods/SDWebImageBPGCoder)
[](https://github.com/SDWebImage/SDWebImageBPGCoder)## What's for
This is a [SDWebImage](https://github.com/SDWebImage/SDWebImage) coder plugin to add [BPG Image Format](https://bellard.org/bpg/) support. Which is built based on the open-sourced [libbpg](https://github.com/mirrorer/libbpg) codec.
This BPG coder plugin support static BPG and animated BPG image decoding. It also include an optional codec based on the `bpgenc` to support static BPG and animated BPG encoding.
## Requirements
+ iOS 9.0
+ macOS 10.11
+ tvOS 9.0
+ watchOS 2.0## Installation
#### CocoaPods
SDWebImageBPGCoder is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'SDWebImageBPGCoder'
```SDWebImageBPGCoder contains subspecs `libbpg` & `bpgenc`. Which integrate the codec plugin for libbpg and custom bpgenc to support BPG image decoding/encoding.
To enable BPG decoding, you should add `libbpg` subspec:
```ruby
pod 'SDWebImageBPGCoder/libbpg'
```To enable BPG encoding, you should add `bpgenc` subspec:
```ruby
pod 'SDWebImageBPGCoder/bpgenc'
```By default will contains only `libbpg` subspec for most people's usage. Using `bpgenc` encoding subspec only if you want BPG encoding.
#### Carthage
SDWebImageBPGCoder is available through [Carthage](https://github.com/Carthage/Carthage). Which use libbpg as dynamic framework.
Carthage does not support like CocoaPods' subspec, since most of user use BPG decoding without x265 library. The framework through Carthage only supports libbpg for BPG decoding.
```
github "SDWebImage/SDWebImageBPGCoder"
```## Usage
To use BPG coder, you should firstly add the `SDWebImageBPGCoder` to the coders manager. Then you can call the View Category method to start load BPG images.
+ Objective-C
```objective-c
SDImageBPGCoder *BPGCoder = [SDImageBPGCoder sharedCoder];
[[SDImageCodersManager sharedManager] addCoder:BPGCoder];
UIImageView *imageView;
[imageView sd_setImageWithURL:url];
```+ Swift
```swift
let BPGCoder = SDImageBPGCoder.shared
SDImageCodersManager.shared.addCoder(BPGCoder)
let imageView: UIImageView
imageView.sd_setImage(with: url)
````SDWebImageBPGCoder` also support BPG encoding (need bpgenc subspec). You can encode `UIImage` to BPG compressed image data.
+ Objective-C
```objectivec
UIImage *image;
NSData *imageData = [image sd_imageDataAsFormat:SDImageFormatBPG];
```+ Swift
```swift
let image;
let imageData = image.sd_imageData(as: .BPG)
```## Screenshot
The images are from [BPG official site](https://bellard.org/bpg/)
## Author
DreamPiggy
## Thanks
[libbpg](https://github.com/mirrorer/libbpg)
## License
SDWebImageBPGCoder is available under the MIT license. See the LICENSE file for more info.
However, when using `bpgenc`, the license will be subject to GPL licence (or commercial licence if you have one). Because we use x265, and use a modified version of `bpgenc` (which is GPL). Check [x265.org](http://x265.org/) and [libbpg](https://github.com/mirrorer/libbpg) for more information.