uiview - How to get a screenshot of a view containing GPUImageView? -
i'm writing image editor iphone app. use gpuimage library present image (on gpuimageview) of sprite on canvas. , use following method screenshot of canvas:
@implementation uiview (snapshotimage) // return snapshot image of view - (uiimage*)snapshot{ uigraphicsbeginimagecontextwithoptions(self.bounds.size,yes,0.0f); cgcontextref context = uigraphicsgetcurrentcontext(); // in ios 7, can use following instead of `-renderincontext:`. should faster. // [self drawviewhierarchyinrect:self.bounds afterscreenupdates:yes]; [self.layer renderincontext:context]; uiimage *capturedimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); return capturedimage; } @end
after used method whole screenshot of key window, field of canvas empty (no image of sprite).
uiview *keywindow = [[uiapplication sharedapplication] keywindow]; uiimage *snapshotiamge = [keywindow snapshot]; // present image on view...
i think there problem screenshot of view containing gpuimageview(s), use opengles render images not quartz. how screenshot of view containing gpuimageview?
and possible cropped image specific cgrect when taking screenshot (like cmd + shift + 4
on mac)?
as found, -renderincontext:
doesn't work opengl es content. you're going need extract processed image gpuimage itself.
to this, call -imagefromcurrentlyprocessedoutput
on filter feeds directly gpuimageview. give uiimage final filtered image within it. can either use directly, or can composite remaining content surrounding views.
Comments
Post a Comment