Monday, September 16, 2013

iOS -- Core Image


  • CIContext. All of the processing of a core image is done in a CIContext. This is somewhat similar to a Core Graphics or OpenGL context.
  • CIImage. This class hold the image data. It can be creating from a UIImage, from an image file, or from pixel data.
  • CIFilter. The filter class has a dictionary that defines the attributes of the particular filter that it represents. Examples of filters are vibrance filters, color inversion filters, cropping filters, and much more.

1.declare
@implementation ViewController
{

    CIContext *context;
    CIFilter *filter;
    CIImage *beginImage;

}

2. change

    NSString *filePath = [[NSBundle mainBundle]pathForResource:@"image" ofType:@"png"];
    
    NSURL *fileNameAndPath = [NSURL fileURLWithPath:filePath];
    
    beginImage = [CIImage imageWithContentsOfURL:fileNameAndPath];
    
    context = [CIContext contextWithOptions:nil];
    
    filter = [CIFilter filterWithName:@"CISepiaTone" keysAndValues:kCIInputImageKey,beginImage,@"inputIntensity",@0.8, nil];
    
    CIImage *outputImage = [filter outputImage];
    
    CGImageRef cgimg = [context createCGImage:outputImage fromRect:[outputImage extent]];

    UIImage *newImage = [UIImage imageWithCGImage:cgimg];
    

    self.imageView.image = newImage;

Sunday, September 15, 2013

iOS - URL SCHEME


To configure URL SCHEME

In Xcode project, info.




Open the app in code:

  NSString *format = @"birdland://";
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:format]];
   
    [[UIApplication sharedApplication] openURL:url];