Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import <Foundation/Foundation.h>
- #import <AppKit/AppKit.h>
- #include <stdio.h>
- int main (int argc, const char * argv[]) {
- //NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- // insert code here...
- //NSLog(@"Hello, World!");
- NSString *path = @"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FinderIcon.icns";
- NSImage* img = [[NSImage alloc] initWithContentsOfFile:path];
- NSArray * imageReps = [NSBitmapImageRep imageRepsWithContentsOfFile:path];
- NSInteger width = 0;
- NSInteger height = 0;
- NSImageRep * imageRep = [imageReps objectAtIndex: 1];
- //NSLog(@"width = %ld",[imageRep pixelsWide]);
- //NSLog(@"height = %ld",[imageRep pixelsHigh]);
- [img setSize: NSMakeSize(128,128)];
- NSData *data = [imageRep representationUsingType:NSPNGFileType properties : nil];
- NSString *pngstr = [data base64EncodedStringWithOptions:0 ];
- int len = [pngstr length];
- char *buf = (char*)malloc(sizeof(char)*(len+1));
- //NSLog(@"urldata = %@",pngstr);
- buf = [pngstr UTF8String];
- printf("%s\n",buf);
- //[pool drain];
- return 0;
- }
Add Comment
Please, Sign In to add comment