среда, 20 июля 2011 г.

NSImage Exif (metadata)

Get metadata from NSImage

  1. + (NSDictionary*) exif : (NSString*) file  
  2. {  
  3.     NSDictionary* dic   =   nil;  
  4.       
  5.     NSURL* url          =   [ NSURL fileURLWithPath : file ];  
  6.       
  7.     if ( url )  
  8.     {  
  9.         CGImageSourceRef source = CGImageSourceCreateWithURL ( (CFURLRef) url, NULL);  
  10.           
  11.         if ( NULL == source )   
  12.         {  
  13. #ifdef _DEBUG  
  14.             CGImageSourceStatus status = CGImageSourceGetStatus ( source );  
  15.             NSLog ( @"Error: file name : %@ - Status: %d", file, status );  
  16. #endif            
  17.         }  
  18.         else  
  19.         {             
  20.             CFDictionaryRef metadataRef = 
  21.             CGImageSourceCopyPropertiesAtIndex ( source, 0, NULL );  
  22.             if ( metadataRef )   
  23.             {  
  24.                 NSDictionary* immutableMetadata = (NSDictionary *)metadataRef;  
  25.                 if ( immutableMetadata )  
  26.                 {                 
  27.                     dic =   
  28.                 [ NSDictionary dictionaryWithDictionary : (NSDictionary *)metadataRef ];  
  29.                 }                                          
  30.                   
  31.                 CFRelease ( metadataRef );  
  32.             }  
  33.               
  34.             CFRelease(source);  
  35.             source = nil;  
  36.         }  
  37.     }  
  38.       
  39.     return dic;  
  40. }  

.........................................

  1. NSDictionary* dic = [ User_ImageLoader exif : filename ];  
  2. if ( dic )  
  3. {  
  4.     NSString* s     =   [ dic valueForKey : @"Orientation" ];  
  5.       
  6.     NSLog(@"Image : %@ - orentation : %d", filename, [ s intValue ] );  
  7. }  

LOG


2011-07-21 00:09:44.579 test.app [12105:7f03] Image : /Users/alexey/Desktop/Works/EXIF Orientation Sample Images/7.jpg - orentation : 7
2011-07-21 00:09:45.908 test.app [12105:7f03] Image : /Users/alexey/Desktop/Works/EXIF Orientation Sample Images/8.jpg - orentation : 8

Create CGImageRef with EXIF Orientation

воскресенье, 19 июня 2011 г.

NSMutableDictionary to NSUserDefaults

  1. NSMutableDictionary* dic = [ [ NSMutableDictionary alloc ] initWithObjectsAndKeys :   
  2.                             @"500", @"MaxLoadedImages",   
  3.                             @"10",  @"RequestMaxImages",  
  4.                             nil ];   
  5. if ( dic )  
  6. {         
  7.     [ [ NSUserDefaults standardUserDefaults ] setObject : dic forKey : @"flickr.com" ];       
  8.     [ dic release ];  
  9. }  

.............................

  1. NSDictionary* settings          =   [ [ NSUserDefaults standardUserDefaults ] objectForKey : @"flickr.com" ];  
  2. NSInteger maxLoadedImages       =   [ [ settings objectForKey : @"MaxLoadedImages" ] integerValue ];  
  3. NSInteger requestMaxImages      =   [ [ settings objectForKey : @"RequestMaxImages" ] integerValue ];  
  4.   
  5. NSLog(@"settings : %@", settings);  

LOG

2011-06-19 14:07:34.600 test.app[3464:6b03] settings : {
MaxLoadedImages = 500;
RequestMaxImages = 10;
}

пятница, 13 мая 2011 г.

ePic for Mac v1.1


What's New in Version 1.1

* Smoothing the edges of the pictures
* Improved stability of the application
* Accelerate work wih service Flickr (fixed bug for search by keyword)
* Fixed minor bugs in interface (fixed for old system's)
* Impover manage your viewing with the mouse, keyboard (nice shortcuts)

Download via Mac App Store (itunes link)
Donwload via Site (site link)

суббота, 9 апреля 2011 г.

3d Slide Show (ePic)



ePic 3d slide show with fantastic physics.

Features

- Show photo from the flickr.com, iPhoto albums, or local folders.
- Physics-based filmstrip display
- Classic slide show mode with more effects
- Turn the app into a screen saver mode after a certain amount of inactivity
- Unique concept with physics

Download via Mac App Store




суббота, 20 ноября 2010 г.

Get resource from bundle screensaver

  1. NSBundle* bundle = [ NSBundle bundleForClass : [ class_id class ] ];    
  2. // class_id - self gui    
  3. NSString* fileName = [ bundle pathForResource:@"logo" ofType:@"png" ];  

вторник, 7 сентября 2010 г.

NSString to wstring

NSString to std::wstring & std::wstring to NSString

  1. std::wstring NSStringToStringW ( NSString* Str )   
  2. {   
  3.     NSStringEncoding pEncode    =   CFStringConvertEncodingToNSStringEncoding ( kCFStringEncodingUTF32LE );   
  4.     NSData* pSData              =   [ Str dataUsingEncoding : pEncode ];    
  5.    
  6.     return std::wstring ( (wchar_t*) [ pSData bytes ], [ pSData length] / sizeof ( wchar_t ) );   
  7. }   
  8.    
  9. NSString* StringWToNSString ( const std::wstring& Str )   
  10. {   
  11.     NSString* pString = [ [ NSString alloc ]    
  12.                         initWithBytes : (char*)Str.data()   
  13.                                length : Str.size() * sizeof(wchar_t)   
  14.                              encoding : CFStringConvertEncodingToNSStringEncoding ( kCFStringEncodingUTF32LE ) ];   
  15.     return pString;   
  16. }  
.

понедельник, 6 сентября 2010 г.

Create a context for the drawing of the buffer.

CGContext Reference
CGColorSpace Reference

  1. int ImageWidth          =   512;   
  2. int ImageHeight         =   512;   
  3.    
  4. unsigned char* pBuffer  =   NULL;   
  5.    
  6. CGContextRef CreateBitmapContext ()   
  7. {   
  8.     CGContextRef    pContext        =   NULL;   
  9.     CGColorSpaceRef ColorSpace  =   CGColorSpaceCreateDeviceRGB ();   
  10.    
  11.     int bitmapByteCount     =   ( ImageWidth * 4 );   
  12.     int bitmapBytesPerRow   =   ( bitmapBytesPerRow * ImageWidth );   
  13.    
  14.     pBuffer = new unsigned char [ bitmapByteCount ];   
  15.    
  16.     if ( NULL == pBuffer )   
  17.     {   
  18.         delete [] pBuffer;   
  19.    
  20.         CGColorSpaceRelease ( ColorSpace );   
  21.    
  22.         return NULL;   
  23.     }   
  24.    
  25.     pContext    =   CGBitmapContextCreate (   
  26.         pBuffer,   
  27.         ImageWidth,   
  28.         ImageHeight,   
  29.         8,   
  30.         bitmapBytesPerRow,   
  31.         ColorSpace,   
  32.         kCGImageAlphaPremultipliedLast );   
  33.    
  34.     if ( NULL == pContext )   
  35.     {   
  36.         delete [] m_pBuffer;   
  37.    
  38.         CGColorSpaceRelease( colorSpace );   
  39.    
  40.         return NULL;   
  41.     }   
  42.    
  43.     CGColorSpaceRelease ( ColorSpace );   
  44.    
  45.     return pContext;   
  46. }  
.