Ich versuche, einen Filter oder ein Bild mit einem Filter über ein anderes Bild zu schieben. Ich habe ein Video von eingeschlossen, was ich versuche Snap chat filter exampleZiel c - Schieben Sie ein Bild/Filter über ein Bild
Zur Zeit zu tun ich eine UIView mit dem Originalbild (self.mainImage.image), und ich erstellen Sie einen Filter mit dem folgenden Code:
- (void)applyBWFilter {
UIImage *img = [_images peak];
// Add B&W filter
// Create image rectangle with current image width/height
CGRect imageRect = CGRectMake(0, 0, img.size.width, img.size.height);
// Grayscale color space
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
// Create bitmap content with current image size and grayscale colorspace
CGContextRef context = CGBitmapContextCreate(nil, img.size.width, img.size.height, 8, 0, colorSpace, kCGImageAlphaNone);
// Draw image into current context, with specified rectangle
// using previously defined context (with grayscale colorspace)
CGContextDrawImage(context, imageRect, [img CGImage]);
// Create bitmap image info from pixel data in current context
CGImageRef imageRef = CGBitmapContextCreateImage(context);
// Create a new UIImage object
self.mainImage.image = [UIImage imageWithCGImage:imageRef];
// Release colorspace, context and bitmap information
CGColorSpaceRelease(colorSpace);
CGContextRelease(context);
CFRelease(imageRef);
}
Wie kann ich das neue Bild wie im Beispiel über das alte Bild schieben?