Skip to content

Commit a47710f

Browse files
committed
Added macOS Demo for webp encoding test
1 parent 7e70ec8 commit a47710f

File tree

20 files changed

+1133
-4
lines changed

20 files changed

+1133
-4
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* This file is part of the SDWebImage package.
3+
* (c) DreamPiggy <[email protected]>
4+
*
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*/
8+
9+
#import <Cocoa/Cocoa.h>
10+
11+
@interface AppDelegate : NSObject <NSApplicationDelegate>
12+
13+
14+
@end
15+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* This file is part of the SDWebImage package.
3+
* (c) DreamPiggy <[email protected]>
4+
*
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*/
8+
9+
#import "AppDelegate.h"
10+
11+
@interface AppDelegate ()
12+
13+
14+
@end
15+
16+
@implementation AppDelegate
17+
18+
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
19+
// Insert code here to initialize your application
20+
}
21+
22+
23+
- (void)applicationWillTerminate:(NSNotification *)aNotification {
24+
// Insert code here to tear down your application
25+
}
26+
27+
28+
- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app {
29+
return YES;
30+
}
31+
32+
33+
@end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}
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+
"scale" : "1x",
6+
"size" : "16x16"
7+
},
8+
{
9+
"idiom" : "mac",
10+
"scale" : "2x",
11+
"size" : "16x16"
12+
},
13+
{
14+
"idiom" : "mac",
15+
"scale" : "1x",
16+
"size" : "32x32"
17+
},
18+
{
19+
"idiom" : "mac",
20+
"scale" : "2x",
21+
"size" : "32x32"
22+
},
23+
{
24+
"idiom" : "mac",
25+
"scale" : "1x",
26+
"size" : "128x128"
27+
},
28+
{
29+
"idiom" : "mac",
30+
"scale" : "2x",
31+
"size" : "128x128"
32+
},
33+
{
34+
"idiom" : "mac",
35+
"scale" : "1x",
36+
"size" : "256x256"
37+
},
38+
{
39+
"idiom" : "mac",
40+
"scale" : "2x",
41+
"size" : "256x256"
42+
},
43+
{
44+
"idiom" : "mac",
45+
"scale" : "1x",
46+
"size" : "512x512"
47+
},
48+
{
49+
"idiom" : "mac",
50+
"scale" : "2x",
51+
"size" : "512x512"
52+
}
53+
],
54+
"info" : {
55+
"author" : "xcode",
56+
"version" : 1
57+
}
58+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}

Example/SDWebImageWebPCoderExample-macOS/Base.lproj/Main.storyboard

Lines changed: 717 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict/>
5+
</plist>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* This file is part of the SDWebImage package.
3+
* (c) DreamPiggy <[email protected]>
4+
*
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*/
8+
9+
#import <Cocoa/Cocoa.h>
10+
11+
@interface ViewController : NSViewController
12+
13+
14+
@end
15+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* This file is part of the SDWebImage package.
3+
* (c) DreamPiggy <[email protected]>
4+
*
5+
* For the full copyright and license information, please view the LICENSE
6+
* file that was distributed with this source code.
7+
*/
8+
9+
#import "ViewController.h"
10+
#import <SDWebImageWebPCoder/SDWebImageWebPCoder.h>
11+
#import <SDWebImage/SDWebImage.h>
12+
13+
@implementation ViewController
14+
15+
- (void)viewDidLoad {
16+
[super viewDidLoad];
17+
18+
// Test transcoding
19+
NSString *jpegPath = [NSBundle.mainBundle pathForResource:@"before.jpeg" ofType:nil inDirectory:@"examples/pexels-egor-kamelev-920163"];
20+
NSData *jpegData = [NSData dataWithContentsOfFile:jpegPath];
21+
NSImage *jpegImage = [[NSImage alloc] initWithData:jpegData];
22+
23+
NSData *webpData = [[SDImageWebPCoder sharedCoder] encodedDataWithImage:jpegImage format:SDImageFormatWebP options:nil];
24+
NSString *webpPath = [[jpegPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"after.webp"];
25+
BOOL success = [webpData writeToFile:webpPath atomically:YES];
26+
NSAssert(success, @"Encode WebP success");
27+
}
28+
29+
30+
- (void)setRepresentedObject:(id)representedObject {
31+
[super setRepresentedObject:representedObject];
32+
33+
// Update the view, if already loaded.
34+
}
35+
36+
37+
@end

0 commit comments

Comments
 (0)