]> git.saurik.com Git - winterboard.git/blob - UIImages.mm
Checkpointing before integration experiment.
[winterboard.git] / UIImages.mm
1 #import <Foundation/Foundation.h>
2 #import <CoreGraphics/CoreGraphics.h>
3
4 #import <UIKit/UIKeyboard.h>
5 #import <UIKit/UIImage.h>
6
7 extern "C" {
8 #include <mach-o/nlist.h>
9 }
10
11 extern "C" NSData *UIImagePNGRepresentation(UIImage *image);
12
13 int main(int argc, char *argv[]) {
14 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
15
16 struct nlist nl[4];
17 memset(nl, 0, sizeof(nl));
18 nl[0].n_un.n_name = (char *) "___mappedImages";
19 nl[1].n_un.n_name = (char *) "__UISharedImageInitialize";
20 nl[2].n_un.n_name = (char *) "_LoadMappedImageRef";
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;
24 CGImageRef (*_LoadMappedImageRef)(CFStringRef) = (CGImageRef (*)(CFStringRef)) nl[2].n_value;
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];
32 CGImageRef ref;
33 if (_LoadMappedImageRef == NULL)
34 ref = reinterpret_cast<CGImageRef>([*images objectForKey:key]);
35 else
36 ref = _LoadMappedImageRef(reinterpret_cast<CFStringRef>(key));
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 }