пятница, 16 августа 2013 г.

ePic 1.8 (summer update)



What's New in Version 1.8

● Screensaver supports multiple monitors
● Add support your Google+ albums
● Display photo metadata
● Add support your photo-sessions and stories on 500px
● Lots of smaller tweaks and fixes
● Stability improvements

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

среда, 7 ноября 2012 г.

ePic 1.6 (retina update)


What's New in Version 1.6 

Features:
* Retina support
* Moutain Lion support
* Update design of control panel

Bug fix:
* Memory and CPU improvements
* Fix drag and drop
* Lots of smaller tweaks and fixes
* Stability improvements

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

Epicreal Team

Twitter
Facebook

вторник, 11 сентября 2012 г.

Create CGImageRef with EXIF Orientation

  1. static inline double rad (int alpha)  
  2. {  
  3.     return ((alpha * pi)/180);  
  4. }  
  5.   
  6. static CGImageRef RotateImageWithFlip (CGImageRef source, float angle, 
  7.                                    BOOL flipX, BOOL flipY)  
  8. {  
  9.     float fX    =  fabs ( cos ( rad ( angle ) ) );  
  10.     float fY    =  fabs ( sin ( rad ( angle ) ) );  
  11.       
  12.     float dW    =  (float)CGImageGetWidth  (source) * fX +
  13.                     (float)CGImageGetHeight (source) * fY;  
  14.     float dH    =  (float)CGImageGetWidth  (source) * fY +
  15.                     (float)CGImageGetHeight (source) * fX;  
  16.       
  17.     CGContextRef context = CGBitmapContextCreate (NULL,  
  18.                                           (size_t)dW, (size_t)dH,   
  19.                                           CGImageGetBitsPerComponent(source),   
  20.                                           0,   
  21.                                           CGImageGetColorSpace(source),  
  22.                                           kCGImageAlphaPremultipliedLast);  
  23.       
  24.     CGContextSetAllowsAntialiasing(context, NO);  
  25.     CGContextSetShouldAntialias(context, NO);  
  26.     CGContextSetInterpolationQuality (context, kCGInterpolationLow);  
  27.       
  28.     CGAffineTransform transform =
  29.     CGAffineTransformMakeTranslation(flipX?dW:0.0f,flipY?dH:0.0f);  
  30.     transform = CGAffineTransformScale (transform,flipX?-1.0:1.0f,flipY?-1.0: 1.0f);  
  31.   
  32.     if (0.0f != angle)  
  33.     {  
  34.         CGAffineTransform rot = CGAffineTransformMakeTranslation (dW*0.5f,dH*0.5f);  
  35.         rot                   = CGAffineTransformRotate(rot, rad ( angle ));  
  36.         rot                   = CGAffineTransformTranslate (rot,-dH*0.5f,-dW*0.5f);  
  37.         transform             = CGAffineTransformConcat(rot, transform);  
  38.     }  
  39.       
  40.     CGContextConcatCTM(context, transform);  
  41.       
  42.     CGContextDrawImage(context, CGRectMake (0, 0, CGImageGetWidth (source),   
  43.                                                     CGImageGetHeight (source)), source);      
  44.     CGContextFlush(context);      
  45.     CGImageRef rotated  =   CGBitmapContextCreateImage(context);  
  46.     CGContextRelease(context);  
  47.   
  48.     return rotated;  
  49. }  

  50. static CGImageRef RotateWithEXIF (CGImageRef source, int orientation)  
  51. {  
  52.     switch (orientation)  
  53.     {  
  54.         case 2:  
  55.             return RotateImageWithFlip (source, 0, YES, NO);  
  56.             break;  
  57.         case 3:  
  58.             return RotateImageWithFlip (source, 0, YES, YES);  
  59.             break;  
  60.         case 4:  
  61.             return RotateImageWithFlip (source, 0, NO, YES);  
  62.             break;  
  63.   
  64.         case 5:  
  65.             return RotateImageWithFlip (source, 90, NO, YES);  
  66.             break;  
  67.         case 6:  
  68.             return RotateImageWithFlip (source, -90, NO, NO);  
  69.             break;  
  70.               
  71.         case 7:  
  72.             return RotateImageWithFlip (source, 90, YES, NO);  
  73.             break;  
  74.         case 8:  
  75.             return RotateImageWithFlip (source, -90, YES, YES);  
  76.             break;  
  77.               
  78.         default:  
  79.             break;  
  80.     }  
  81.       
  82.     return NULL;  
  83. }  

вторник, 7 августа 2012 г.

Preparing applications for 10.8 (HiDPI)

All you need to make the developers, it is properly configured to work with the regime HiDPI.

If the application is actively using OpenGL.

When initializing the NS*View is bound to 3D-context, do check the retina.

  1. #if (defined(MAC_OS_X_VERSION_10_7)) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7  
  2.         if ( [ NSApplication usingLionOSX ] )  
  3.         {  
  4.           NSRect baseBounds = [ self bounds ];  
  5.           NSRect hdpiBounds = [ self convertRectToBacking : baseBounds ];  
  6.            
  7.           if (NO == NSEqualSizes(baseBounds.size, hdpiBounds.size))  
  8.           {            
  9.               [ self setWantsBestResolutionOpenGLSurface : YES ];  
  10.           }  
  11.         }  
  12. #endif  

If you change the size of the application recalculate dimensions.

  1. - (void) updateBounds  
  2. {  
  3.     NSRect  baseBounds  =   [ self bounds ];  
  4.       
  5. #if (defined(MAC_OS_X_VERSION_10_7)) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7  
  6.     if ( [ NSApplication usingLionOSX ] )  
  7.     {        
  8.         baseBounds      =   [ self convertRectToBacking : baseBounds ];  
  9.     }   
  10. #endif  
  11.   ....  
  12.    
  13.   glClearColor ( 0.0f, 0.0f, 0.0f, 1.0f );   
  14.   glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );   
  15.   glViewport (0.0f, 0.0f, baseBounds.size.width, baseBounds.size.height );  
  16.   ....  
  17.   
  18. }  

About the class NSImage.

All the work is not in pixels but in points. Released two QuartzCore used to work with all images or do a little fix-resize the output image.

  1. NSImageRep* rep = [[img representations] objectAtIndex:0];    // fix HDPI  
  2. if (rep)  
  3. {  
  4.        NSSize size = NSMakeSize ([rep pixelsWide], [rep pixelsHigh]);  
  5.        [img setSize : size];  
  6. }  


Resources and rewards.

All UI elements are presented in the form of bitmap images must be properly scaled up twice. XCode automatically to pick up, just add '* texture.name * @ 2x.tiff ' copy of your texture to the project. If you need to manually create bitmaps from the resource that is the method of [NSimage imageNamed: @ "* texture.name *"] correctly load the desired image.

Do not forget about the icon. This designer's work - painting the icons in the amount of 1024x1024px.



понедельник, 23 апреля 2012 г.

ePic 1.5 (spring version)


What's New in Version 1.5


* add surface text source description and dates photos create
* show user content for Picasa albums and Flickr photosets and galleries
* save images via hold  ‘⌘’  and drag drop to desktop
* fixed bug with open panel
* fixed bug trackpad pinch gesture
* fiixed various crashes



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


Epicreal Team 
Twitter
Facebook

пятница, 2 марта 2012 г.

How to load custom font from file (NSFont from file)

Load a NSFont from bundle.

First, add ApplicationServices.framework to project.

  1. + (CTFontRef) fontFromBundle : (NSString*) fontName withHeight : (CGFloat) height;  
  2. {  
  3.     // Get the path to our custom font and create a data provider.  
  4.     NSString* fontPath = [[NSBundle mainBundle] pathForResource : fontName
  5.                                                          ofType : @"ttf" ];   
  6.     if (nil==fontPath)  
  7.         return NULL;  
  8.       
  9.     CGDataProviderRef dataProvider =
  10.     CGDataProviderCreateWithFilename ([fontPath UTF8String]);  
  11.     if (NULL==dataProvider)  
  12.         return NULL;  
  13.       
  14.     // Create the font with the data provider, then release the data provider.  
  15.     CGFontRef fontRef = CGFontCreateWithDataProvider ( dataProvider );  
  16.     if ( NULL == fontRef )  
  17.     {  
  18.         CGDataProviderRelease ( dataProvider );   
  19.         return NULL;  
  20.     }      
  21.       
  22.     CTFontRef fontCore = CTFontCreateWithGraphicsFont(fontRef, height, NULL, NULL);  
  23.     CGDataProviderRelease (dataProvider);   
  24.     CGFontRelease(fontRef);  
  25.       
  26.     return fontCore;  
  27. }  

In code

  1. CTFontRef bundleFont = [ CustomFonts fontFromBundle : @"MavenPro-Regular"
  2.                                          withHeight : 25 ];  
  3. NSFont* font = (NSFont*)bundleFont;  
  4. ....  
  5. // use NSFont   
  6. ....  
  7. CFRelease(bundleFont);  
  8.    

UPD. works correctly only 10.7+

воскресенье, 22 января 2012 г.

OpenGL FBO (Step by step)

Step by step how to use EXT_framebuffer_object.

Check extenstion

  1. - (BOOL) initFBO  
  2. {  
  3.     // check extension  
  4.     const GLubyte* extensions = glGetString ( GL_EXTENSIONS );  
  5.     if ( extensions )  
  6.     {     
  7.         if(gluCheckExtension((GLubyte*)("GL_EXT_framebuffer_object"), extensions))  
  8.             return YES;  
  9.     }  
  10.     return NO;  
  11. }  

сreate the texture for framebuffer

  1. GLuint textureId      
  2. glGenTextures ( 1, &textureId );  
  3. glBindTexture ( GL_TEXTURE_2D, textureId );  
  4. glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );  
  5. glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );  
  6. glTexImage2D ( GL_TEXTURE_2D, 0, 4, TextureWidth, TextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0 );  

сreate framebuffer (FBO)

  1. GLuint frameBufferId;  
  2.   
  3. glGenFramebuffersEXT ( 1, &frameBufferId ); // 0 - main buffer, framebufferId > 0  
  4. glBindFramebufferEXT ( GL_FRAMEBUFFER_EXT, frameBufferId );  
  5. glFramebufferTexture2DEXT ( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,  
  6.  GL_TEXTURE_2D, textureId, 0 ); // attach texture to fbo  
  7.   
  8. // check fbo ( glCheckFramebufferStatusEXT )  
  9. // ...  
  10.   
  11. glBindFramebufferEXT ( GL_FRAMEBUFFER_EXT, 0 ); // select main buffer  

сheck framebuffer

  1. GLenum status = glCheckFramebufferStatusEXT ( GL_FRAMEBUFFER_EXT );  
  2. if ( status != GL_FRAMEBUFFER_COMPLETE_EXT )  
  3. {  
  4.     switch ( status )  
  5.     {  
  6.         case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:  
  7.             NSLog(@"FrameBuffer Error - GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT");  
  8.             break;  
  9.         case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:  
  10.             NSLog(@"FrameBufferErGL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT");  
  11.             break;  
  12.         case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:  
  13.             NSLog(@"FrameBuffer Error - GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT");  
  14.             break;  
  15.         case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:  
  16.             NSLog(@"FrameBuffer Error - GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT");  
  17.             break;  
  18.         case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:  
  19.             NSLog(@"FrameBuffer Error - GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT");                            
  20.             break;  
  21.         case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:  
  22.             NSLog(@"FrameBuffer Error - GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT");  
  23.             break;  
  24.         case GL_FRAMEBUFFER_UNSUPPORTED_EXT:  
  25.             NSLog(@"FrameBuffer Error - GL_FRAMEBUFFER_UNSUPPORTED_EXT");  
  26.             break;  
  27.         default:  
  28.             NSLog(@"FrameBuffer Error - Unknown error");  
  29.               
  30.             break;  
  31.     }  
  32.         
  33.     return NO;  
  34. }  

use in the code

  1. glBindFramebufferEXT ( GL_FRAMEBUFFER_EXT, frameBufferId ); // select fbo
  2.   
  3. glClearColor ( 0.0f, 0.0f, 1.0f, 1.0f );   
  4. glClear ( GL_COLOR_BUFFER_BIT );  
  5.   
  6. // render into texture ( update model view transforms )
  7. // ...  
  8.   
  9. glBindFramebufferEXT ( GL_FRAMEBUFFER_EXT, 0 );      // select main buffer  

We can use the texture for post-effects. Do not forget to delete resources ;-)

Example OpenGL FBO (github)