iphone - Using GPUImage, how would I split image into 4 and apply different filters to all 4 corners and recombine? -
i want similar gpu logo, different filter on each corner.
so far have managed achieve image size half of original. here simplification of code:
_croptopleft = [[gpuimagecropfilter alloc] initwithcropregion:cgrectmake(0.0, 0.0, 0.5, 0.5)]; cgaffinetransform toplefttransform = cgaffinetransformmaketranslation(-1, -1); toplefttransform = cgaffinetransformscale(toplefttransform, 0.5, 0.5); _transformtl = [[gpuimagetransformfilter alloc] init]; _transformtl.affinetransform = toplefttransform; // set pipeline: image -> crop -> transform // don't apply effects corners now, // try recreate original image [imagesource addtarget:_croptopleft]; [_croptopleft addtarget:_transformtl]; // same other corners... tr, bl & br // recombine // can apply 2 inputs blend filter, combine using 3 filteres // blend filteres `gpuimagenormalblendfilter` instances [_transformtl addtarget:_blendfiltertop]; [_transformtr addtarget:_blendfiltertop]; [_transformbl addtarget:_blendfilterbottom]; [_transformbr addtarget:_blendfilterbottom]; [_blendfiltertop addtarget:_blendfilterall]; [_blendfilterbottom addtarget:_blendfilterall]; [_blendfilterall addtarget:_mygpuimageview];
the issue when corner of image cropped, canvas size halved.
i believe half size used through pipeline.
my work around half corner again transform, results in 1/2 resolution output image.
i think easiest solution is, instead of messing of crops , transforms, create shader set alpha 0 on entire image except quadrant applying filter to.
your filter chain this...
for each quadrant:
apply effect filter -> apply set alpha filter -> on blend previous pass
Comments
Post a Comment