- static inline double rad (int alpha)
- {
- return ((alpha * pi)/180);
- }
- static CGImageRef RotateImageWithFlip (CGImageRef source, float angle,
- BOOL flipX, BOOL flipY)
- {
- float fX = fabs ( cos ( rad ( angle ) ) );
- float fY = fabs ( sin ( rad ( angle ) ) );
- float dW = (float)CGImageGetWidth (source) * fX +
- (float)CGImageGetHeight (source) * fY;
- float dH = (float)CGImageGetWidth (source) * fY +
- (float)CGImageGetHeight (source) * fX;
- CGContextRef context = CGBitmapContextCreate (NULL,
- (size_t)dW, (size_t)dH,
- CGImageGetBitsPerComponent(source),
- 0,
- CGImageGetColorSpace(source),
- kCGImageAlphaPremultipliedLast);
- CGContextSetAllowsAntialiasing(context, NO);
- CGContextSetShouldAntialias(context, NO);
- CGContextSetInterpolationQuality (context, kCGInterpolationLow);
- CGAffineTransform transform =
- CGAffineTransformMakeTranslation(flipX?dW:0.0f,flipY?dH:0.0f);
- transform = CGAffineTransformScale (transform,flipX?-1.0:1.0f,flipY?-1.0: 1.0f);
- if (0.0f != angle)
- {
- CGAffineTransform rot = CGAffineTransformMakeTranslation (dW*0.5f,dH*0.5f);
- rot = CGAffineTransformRotate(rot, rad ( angle ));
- rot = CGAffineTransformTranslate (rot,-dH*0.5f,-dW*0.5f);
- transform = CGAffineTransformConcat(rot, transform);
- }
- CGContextConcatCTM(context, transform);
- CGContextDrawImage(context, CGRectMake (0, 0, CGImageGetWidth (source),
- CGImageGetHeight (source)), source);
- CGContextFlush(context);
- CGImageRef rotated = CGBitmapContextCreateImage(context);
- CGContextRelease(context);
- return rotated;
- }
- static CGImageRef RotateWithEXIF (CGImageRef source, int orientation)
- {
- switch (orientation)
- {
- case 2:
- return RotateImageWithFlip (source, 0, YES, NO);
- break;
- case 3:
- return RotateImageWithFlip (source, 0, YES, YES);
- break;
- case 4:
- return RotateImageWithFlip (source, 0, NO, YES);
- break;
- case 5:
- return RotateImageWithFlip (source, 90, NO, YES);
- break;
- case 6:
- return RotateImageWithFlip (source, -90, NO, NO);
- break;
- case 7:
- return RotateImageWithFlip (source, 90, YES, NO);
- break;
- case 8:
- return RotateImageWithFlip (source, -90, YES, YES);
- break;
- default:
- break;
- }
- return NULL;
- }
вторник, 11 сентября 2012 г.
Create CGImageRef with EXIF Orientation
вторник, 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.
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.
Do not forget about the icon. This designer's work - painting the icons in the amount of 1024x1024px.
If the application is actively using OpenGL.
When initializing the NS*View is bound to 3D-context, do check the retina.
- #if (defined(MAC_OS_X_VERSION_10_7)) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if ( [ NSApplication usingLionOSX ] )
- {
- NSRect baseBounds = [ self bounds ];
- NSRect hdpiBounds = [ self convertRectToBacking : baseBounds ];
- if (NO == NSEqualSizes(baseBounds.size, hdpiBounds.size))
- {
- [ self setWantsBestResolutionOpenGLSurface : YES ];
- }
- }
- #endif
If you change the size of the application recalculate dimensions.
- - (void) updateBounds
- {
- NSRect baseBounds = [ self bounds ];
- #if (defined(MAC_OS_X_VERSION_10_7)) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if ( [ NSApplication usingLionOSX ] )
- {
- baseBounds = [ self convertRectToBacking : baseBounds ];
- }
- #endif
- ....
- glClearColor ( 0.0f, 0.0f, 0.0f, 1.0f );
- glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
- glViewport (0.0f, 0.0f, baseBounds.size.width, baseBounds.size.height );
- ....
- }
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.
- NSImageRep* rep = [[img representations] objectAtIndex:0]; // fix HDPI
- if (rep)
- {
- NSSize size = NSMakeSize ([rep pixelsWide], [rep pixelsHigh]);
- [img setSize : size];
- }
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
Donwload via Site (site link)
Epicreal Team
пятница, 2 марта 2012 г.
How to load custom font from file (NSFont from file)
Load a NSFont from bundle.
First, add ApplicationServices.framework to project.
First, add ApplicationServices.framework to project.
- + (CTFontRef) fontFromBundle : (NSString*) fontName withHeight : (CGFloat) height;
- {
- // Get the path to our custom font and create a data provider.
- NSString* fontPath = [[NSBundle mainBundle] pathForResource : fontName
- ofType : @"ttf" ];
- if (nil==fontPath)
- return NULL;
- CGDataProviderRef dataProvider =
- CGDataProviderCreateWithFilename ([fontPath UTF8String]);
- if (NULL==dataProvider)
- return NULL;
- // Create the font with the data provider, then release the data provider.
- CGFontRef fontRef = CGFontCreateWithDataProvider ( dataProvider );
- if ( NULL == fontRef )
- {
- CGDataProviderRelease ( dataProvider );
- return NULL;
- }
- CTFontRef fontCore = CTFontCreateWithGraphicsFont(fontRef, height, NULL, NULL);
- CGDataProviderRelease (dataProvider);
- CGFontRelease(fontRef);
- return fontCore;
- }
In code
- CTFontRef bundleFont = [ CustomFonts fontFromBundle : @"MavenPro-Regular"
- withHeight : 25 ];
- NSFont* font = (NSFont*)bundleFont;
- ....
- // use NSFont
- ....
- CFRelease(bundleFont);
UPD. works correctly only 10.7+
воскресенье, 22 января 2012 г.
OpenGL FBO (Step by step)
Step by step how to use EXT_framebuffer_object.
Check extenstion
- - (BOOL) initFBO
- {
- // check extension
- const GLubyte* extensions = glGetString ( GL_EXTENSIONS );
- if ( extensions )
- {
- if(gluCheckExtension((GLubyte*)("GL_EXT_framebuffer_object"), extensions))
- return YES;
- }
- return NO;
- }
сreate the texture for framebuffer
- GLuint textureId
- glGenTextures ( 1, &textureId );
- glBindTexture ( GL_TEXTURE_2D, textureId );
- glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
- glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
- glTexImage2D ( GL_TEXTURE_2D, 0, 4, TextureWidth, TextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0 );
сreate framebuffer (FBO)
- GLuint frameBufferId;
- glGenFramebuffersEXT ( 1, &frameBufferId ); // 0 - main buffer, framebufferId > 0
- glBindFramebufferEXT ( GL_FRAMEBUFFER_EXT, frameBufferId );
- glFramebufferTexture2DEXT ( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, textureId, 0 ); // attach texture to fbo
- // check fbo ( glCheckFramebufferStatusEXT )
- // ...
- glBindFramebufferEXT ( GL_FRAMEBUFFER_EXT, 0 ); // select main buffer
сheck framebuffer
- GLenum status = glCheckFramebufferStatusEXT ( GL_FRAMEBUFFER_EXT );
- if ( status != GL_FRAMEBUFFER_COMPLETE_EXT )
- {
- switch ( status )
- {
- case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
- NSLog(@"FrameBuffer Error - GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT");
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
- NSLog(@"FrameBufferErGL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT");
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
- NSLog(@"FrameBuffer Error - GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT");
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
- NSLog(@"FrameBuffer Error - GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT");
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
- NSLog(@"FrameBuffer Error - GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT");
- break;
- case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
- NSLog(@"FrameBuffer Error - GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT");
- break;
- case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
- NSLog(@"FrameBuffer Error - GL_FRAMEBUFFER_UNSUPPORTED_EXT");
- break;
- default:
- NSLog(@"FrameBuffer Error - Unknown error");
- break;
- }
- return NO;
- }
use in the code
- glBindFramebufferEXT ( GL_FRAMEBUFFER_EXT, frameBufferId ); // select fbo
- glClearColor ( 0.0f, 0.0f, 1.0f, 1.0f );
- glClear ( GL_COLOR_BUFFER_BIT );
- // render into texture ( update model view transforms )
- // ...
- 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)
вторник, 3 января 2012 г.
ePic for Mac 1.4 (winter release)

What's New in Version 1.4
* Full support for OS X Lion, including full-screen mode
* Improved support multi-touch gestures to Magic Trackpad and Magic Mouse
* Support Aperture libraries
* Support Picasa web albums
* Support iPhoto albums
* New mode for 3D presentation ( Breath presentation )
* New SlideShow effects ( two nice effect's )
* Ability to hide the control panel
* Function detailed view your photos in a Slide Show
* Many minor fixes
Donwload via Site (site link)
Epicreal Team Links
вторник, 4 октября 2011 г.
ePic for Mac 1.3 (release MAS)

What's New in Version 1.3
* Full support for OS X Lion, including full-screen mode
* Improved support multi-touch gestures to Magic Trackpad and Magic Mouse
* Support Aperture libraries
* Support Picasa web albums
* Support iPhoto albums
* New mode for 3D presentation (Breath presentation)
* New SlideShow effects ( two nice effect's)
* Ability to hide the control panel
* Function detailed view your photos in a Slide Show
* Many minor fixes
Donwload via Site (site link)
Подписаться на:
Сообщения (Atom)

