Perfectly Clear SDK Documentation  9.1.1.325
Examples (iOS)

Using Perfectly Clear in iOS is very simiar to using it on OSX - just load the image and correct with a Preset or individual parameters:

  1. Create engine - this should be done once when the app loads
    PFCENGINE *pEngine = PFC_CreateEngine();
  2. Initialize PFCPARAM
    PFCPARAM param;
    if (bUsePresetFile) {
    // Read parameters from a preset file The_Outdoors.preset
    NSString *path = [[NSBundle mainBundle] pathForResource:@"The_Outdoors"
    ofType:@"preset"];
    NSError* error = nil;
    NSString* content = [NSString stringWithContentsOfFile:path
    encoding:NSUTF8StringEncoding
    error:&error];
    const char *preset = [content cStringUsingEncoding:NSUTF8StringEncoding];
    // Read parameters
    PFC_ReadPresetsFromStream(param, (const char*)preset);
    } else {
    // Alternately you can initialized PFCPARAM using SetParam instead of reading from preset files.
    // This uses iAuto '21 as the default parameters
    PFC_SetParam(param);
    }
    // Optionally, you can override individual parameters:
    // param.fb.bEnabled = TRUE;
    // param.fb.bSmooth = TRUE;
    // param.fb.iSmoothLevel = 100;
  3. Apply Perfectly Clear:
    int status = PFC_AutoCorrect(&im, NULL, param);
  4. Build a new UIImage and display or save it:
    CGDataProviderRef provider = CGDataProviderCreateWithData(NULL,
    pData,
    w * h * 4,
    MBEReleaseDataCallback);
    int bitsPerComponent = 8;
    int bitsPerPixel = 32;
    int bytesPerRow = 4 * w;
    CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
    CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
    CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;
    CGImageRef imf = CGImageCreate(w,
    h,
    bitsPerComponent,
    bitsPerPixel,
    bytesPerRow,
    colorSpaceRef,
    bitmapInfo,
    provider,NULL,NO,renderingIntent);
    UIImage *newImage = [UIImage imageWithCGImage:imf];
  5. and last, cleanup: