Guest User

Untitled

a guest
Jul 21st, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #import <Foundation/Foundation.h>
  2. #import <AppKit/AppKit.h>
  3. #include <stdio.h>
  4.  
  5. int main (int argc, const char * argv[]) {
  6. //NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
  7.  
  8. // insert code here...
  9. //NSLog(@"Hello, World!");
  10.  
  11. NSString *path = @"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FinderIcon.icns";
  12.  
  13. NSImage* img = [[NSImage alloc] initWithContentsOfFile:path];
  14. NSArray * imageReps = [NSBitmapImageRep imageRepsWithContentsOfFile:path];
  15. NSInteger width = 0;
  16. NSInteger height = 0;
  17.  
  18. NSImageRep * imageRep = [imageReps objectAtIndex: 1];
  19. //NSLog(@"width = %ld",[imageRep pixelsWide]);
  20. //NSLog(@"height = %ld",[imageRep pixelsHigh]);
  21.  
  22.  
  23. [img setSize: NSMakeSize(128,128)];
  24. NSData *data = [imageRep representationUsingType:NSPNGFileType properties : nil];
  25. NSString *pngstr = [data base64EncodedStringWithOptions:0 ];
  26. int len = [pngstr length];
  27. char *buf = (char*)malloc(sizeof(char)*(len+1));
  28. //NSLog(@"urldata = %@",pngstr);
  29. buf = [pngstr UTF8String];
  30. printf("%s\n",buf);
  31. //[pool drain];
  32. return 0;
  33. }
Add Comment
Please, Sign In to add comment