]> git.saurik.com Git - winterboard.git/blame - UIImages.mm
Fixed UIImages, fixed jitter aliasing, fixed Themes permissions, and massive code...
[winterboard.git] / UIImages.mm
CommitLineData
ca13798d
JF
1#import <Foundation/Foundation.h>
2#import <CoreGraphics/CoreGraphics.h>
95a5777b
JF
3
4#import <UIKit/UIKeyboard.h>
5#import <UIKit/UIImage.h>
ca13798d
JF
6
7extern "C" {
8 #include <mach-o/nlist.h>
9}
10
95a5777b
JF
11extern "C" NSData *UIImagePNGRepresentation(UIImage *image);
12
ca13798d
JF
13int main(int argc, char *argv[]) {
14 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
15
2acbe5b8 16 struct nlist nl[4];
ca13798d
JF
17 memset(nl, 0, sizeof(nl));
18 nl[0].n_un.n_name = (char *) "___mappedImages";
19 nl[1].n_un.n_name = (char *) "__UISharedImageInitialize";
2acbe5b8 20 nl[2].n_un.n_name = (char *) "_LoadMappedImageRef";
ca13798d
JF
21 nlist("/System/Library/Frameworks/UIKit.framework/UIKit", nl);
22 NSMutableDictionary **images = (id *) nl[0].n_value;
23 void (*__UISharedImageInitialize)(bool) = (void (*)(bool)) nl[1].n_value;
2acbe5b8 24 CGImageRef (*_LoadMappedImageRef)(CFStringRef) = (CGImageRef (*)(CFStringRef)) nl[2].n_value;
ca13798d
JF
25
26 __UISharedImageInitialize(false);
27
28 NSArray *keys = [*images allKeys];
29 for (int i(0), e([keys count]); i != e; ++i) {
30 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
31 NSString *key = [keys objectAtIndex:i];
2acbe5b8
JF
32 CGImageRef ref;
33 if (_LoadMappedImageRef == NULL)
34 ref = reinterpret_cast<CGImageRef>([*images objectForKey:key]);
35 else
36 ref = _LoadMappedImageRef(reinterpret_cast<CFStringRef>(key));
ca13798d
JF
37 UIImage *image = [UIImage imageWithCGImage:ref];
38 NSData *data = UIImagePNGRepresentation(image);
39 [data writeToFile:[NSString stringWithFormat:@"%@", key] atomically:YES];
40 [pool release];
41 }
42
43 [pool release];
44 return 0;
45}