Skip to content

Commit faa331d

Browse files
committed
Initial commit with AVIF image support
1 parent 20e55c3 commit faa331d

File tree

26 files changed

+1811
-34
lines changed

26 files changed

+1811
-34
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ Carthage/Build
3434
# Note: if you ignore the Pods directory, make sure to uncomment
3535
# `pod install` in .travis.yml
3636
#
37-
# Pods/
37+
Pods/

Example/Podfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
use_frameworks!
2-
3-
platform :ios, '8.0'
1+
#use_frameworks!
42

53
target 'SDWebImageAVIFCoder_Example' do
4+
platform :ios, '8.0'
65
pod 'SDWebImageAVIFCoder', :path => '../'
76

87
target 'SDWebImageAVIFCoder_Tests' do
@@ -11,3 +10,8 @@ target 'SDWebImageAVIFCoder_Example' do
1110

1211
end
1312
end
13+
14+
target 'SDWebImageAVIFCoder_Example macOS' do
15+
platform :osx, '10.10'
16+
pod 'SDWebImageAVIFCoder', :path => '../'
17+
end

Example/Podfile.lock

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
PODS:
2+
- libaom (1.0.0)
3+
- libavif (0.1.0):
4+
- libaom
5+
- SDWebImage (5.0.1):
6+
- SDWebImage/Core (= 5.0.1)
7+
- SDWebImage/Core (5.0.1)
8+
- SDWebImageAVIFCoder (0.1.0):
9+
- libavif
10+
- SDWebImage (~> 5.0)
11+
12+
DEPENDENCIES:
13+
- SDWebImageAVIFCoder (from `../`)
14+
15+
SPEC REPOS:
16+
https://github.com/cocoapods/specs.git:
17+
- libaom
18+
- libavif
19+
- SDWebImage
20+
21+
EXTERNAL SOURCES:
22+
SDWebImageAVIFCoder:
23+
:path: "../"
24+
25+
SPEC CHECKSUMS:
26+
libaom: d84044f314a1eac538c20965ac7df6fe6cee6ac6
27+
libavif: 1513b919d6d7beb8fd8cc2e4a71538609409895b
28+
SDWebImage: 27dd2c9ea07a2252f94557c9fbb6105ee94b74c9
29+
SDWebImageAVIFCoder: 66893c86fbaa82c54556186fe9f62a601b27dfd0
30+
31+
PODFILE CHECKSUM: cb60778bff8fb5ce4fbc8792f6079317b7a897be
32+
33+
COCOAPODS: 1.6.1

Example/SDWebImageAVIFCoder.xcodeproj/project.pbxproj

Lines changed: 213 additions & 19 deletions
Large diffs are not rendered by default.

Example/SDWebImageAVIFCoder.xcworkspace/contents.xcworkspacedata

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/SDWebImageAVIFCoder/SDViewController.m

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//
88

99
#import "SDViewController.h"
10+
#import <SDWebImage/SDWebImage.h>
11+
#import <SDWebImageAVIFCoder/SDImageAVIFCoder.h>
1012

1113
@interface SDViewController ()
1214

@@ -17,7 +19,32 @@ @implementation SDViewController
1719
- (void)viewDidLoad
1820
{
1921
[super viewDidLoad];
20-
// Do any additional setup after loading the view, typically from a nib.
22+
23+
SDImageAVIFCoder *AVIFCoder = [SDImageAVIFCoder sharedCoder];
24+
[[SDImageCodersManager sharedManager] addCoder:AVIFCoder];
25+
NSURL *AVIFURL = [NSURL URLWithString:@"https://raw.githubusercontent.com/AOMediaCodec/av1-avif/master/testFiles/Microsoft/kids_720p.avif"];
26+
NSURL *HDRAVIFURL = [NSURL URLWithString:@"https://raw.githubusercontent.com/AOMediaCodec/av1-avif/master/testFiles/Microsoft/Chimera_10bit_cropped_to_1920x1008.avif"];
27+
28+
CGSize screenSize = [UIScreen mainScreen].bounds.size;
29+
30+
UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, screenSize.width, screenSize.height / 2)];
31+
UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, screenSize.height / 2, screenSize.width, screenSize.height / 2)];
32+
33+
[self.view addSubview:imageView1];
34+
[self.view addSubview:imageView2];
35+
36+
[imageView1 sd_setImageWithURL:AVIFURL placeholderImage:nil options:0 completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
37+
if (image) {
38+
NSLog(@"Single HEIC load success");
39+
}
40+
}];
41+
[imageView2 sd_setImageWithURL:HDRAVIFURL completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
42+
// 10-bit HDR
43+
if (image) {
44+
NSLog(@"HDR AVIF load success");
45+
}
46+
}];
47+
// Do any additional setup after loading the view, typically from a nib.
2148
}
2249

2350
- (void)didReceiveMemoryWarning
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// AppDelegate.h
3+
// SDWebImageAVIFCoder_Example macOS
4+
//
5+
// Created by lizhuoli on 2019/4/14.
6+
// Copyright © 2019 lizhuoli1126@126.com. All rights reserved.
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
11+
@interface AppDelegate : NSObject <NSApplicationDelegate>
12+
13+
14+
@end
15+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// AppDelegate.m
3+
// SDWebImageAVIFCoder_Example macOS
4+
//
5+
// Created by lizhuoli on 2019/4/14.
6+
// Copyright © 2019 lizhuoli1126@126.com. All rights reserved.
7+
//
8+
9+
#import "AppDelegate.h"
10+
11+
@interface AppDelegate ()
12+
13+
@end
14+
15+
@implementation AppDelegate
16+
17+
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18+
// Insert code here to initialize your application
19+
}
20+
21+
22+
- (void)applicationWillTerminate:(NSNotification *)aNotification {
23+
// Insert code here to tear down your application
24+
}
25+
26+
27+
@end
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "mac",
5+
"size" : "16x16",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "mac",
10+
"size" : "16x16",
11+
"scale" : "2x"
12+
},
13+
{
14+
"idiom" : "mac",
15+
"size" : "32x32",
16+
"scale" : "1x"
17+
},
18+
{
19+
"idiom" : "mac",
20+
"size" : "32x32",
21+
"scale" : "2x"
22+
},
23+
{
24+
"idiom" : "mac",
25+
"size" : "128x128",
26+
"scale" : "1x"
27+
},
28+
{
29+
"idiom" : "mac",
30+
"size" : "128x128",
31+
"scale" : "2x"
32+
},
33+
{
34+
"idiom" : "mac",
35+
"size" : "256x256",
36+
"scale" : "1x"
37+
},
38+
{
39+
"idiom" : "mac",
40+
"size" : "256x256",
41+
"scale" : "2x"
42+
},
43+
{
44+
"idiom" : "mac",
45+
"size" : "512x512",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "mac",
50+
"size" : "512x512",
51+
"scale" : "2x"
52+
}
53+
],
54+
"info" : {
55+
"version" : 1,
56+
"author" : "xcode"
57+
}
58+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}

0 commit comments

Comments
 (0)