iphone - Using a CIImage from CIColor in a CIFilter: getting empty image -
i'm trying create cifilter blend mode (like overlay or multiply). relevant code:
// let's try filter here // data nsdata *imagedata = uiimagejpegrepresentation(image, 0.85); // create ci image ciimage *beginimage = [ciimage imagewithdata:imagedata]; ciimage *overlay = [ciimage imagewithcolor:[cicolor colorwithred:0.7 green:0.75 blue:0.9 alpha:0.75]]; // create context cicontext *context = [cicontext contextwithoptions:nil]; // create filter cifilter *filter = [cifilter filterwithname:@"cioverlayblendmode" keysandvalues:@"inputimage", beginimage, @"inputbackgroundimage", overlay, nil]; other filters working okay (like sepia tone), filter requires "inputbackgroundimage" key, blank/empty result ... seems wrong background image.
how use blend mode filter placing solid color on image?
its okay in topic starter's code, 1 fix should be.
nsdata *imagedata = uiimagejpegrepresentation(image, 0.85); // create ci image ciimage *beginimage = [ciimage imagewithdata:imagedata]; ciimage *overlay = [ciimage imagewithcolor:[cicolor colorwithred:0.7 green:0.75 blue:0.9 alpha:0.75]]; //you should crop generated image beginimage size because generated image's size infinite. don't know why, cioverlayblendmode isn't tolerant infinite size overlay = [overlay imagebycroppingtorect:cgrectmake(beginimage.extent.origin.x, beginimage.extent.origin.y, beginimage.extent.size.width, beginimage.extent.size.height)]; // create context cicontext *context = [cicontext contextwithoptions:nil]; // create filter cifilter *filter = [cifilter filterwithname:@"cioverlayblendmode" keysandvalues:@"inputimage", beginimage, @"inputbackgroundimage", overlay, nil];
Comments
Post a Comment