iOS photo save album

//TODO set filter
- (void) selectFilter2:(NSString *) nameLUT{
    // Create filter
    CIFilter * lutFilter = [CIFilter filterWithLUT: @ "filter_lut_2" dimension: 64];
    // Set parameter
    CIImage *ciImage = [[CIImage alloc] initWithImage:[UIImage imageNamed:@"100"]];
    [lutFilter setValue:ciImage forKey:@"inputImage"];
    CIImage *outputImage = [lutFilter outputImage];
    CGColorSpaceRef spaceRef = CGColorSpaceCreateDeviceRGB();
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:(__bridge id _Nonnull)(spaceRef) forKey:kCIContextWorkingColorSpace];
    CIContext *context = [CIContext contextWithOptions:dic];
    CFRelease(spaceRef);
    
    CGImageRef imageRef = [context createCGImage:outputImage fromRect:outputImage.extent];
    newImage = [UIImage imageWithCGImage:imageRef];
    CFRelease(imageRef);
    //save the album
    UIImageWriteToSavedPhotosAlbum(newImage,  self, @selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil);
}

- (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{    NSString *message;
    if (!error) {
        message = @"Successfully saved to album";
        [self showStrAlert:@"Successfully saved to album"];
    }else
    {
        [self showStrAlert:[NSString stringWithFormat:@"%@",error]];
    }
}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326485506&siteId=291194637