iphone - CIPixellate output image size is different -
i using cipixellate pixelating image in ios6. results in bigger image. how can keep original size?
nsdata *imagedata = [nsdata datawithdata:uiimagejpegrepresentation(capturedimageview.image, 1.0)];//[nsdata datawithdata:uiimagepngrepresentation(capturedimageview.image)]; beginimage = [ciimage imagewithdata:imagedata]; context = [cicontext contextwithoptions:[nsdictionary dictionarywithobject:[nsnumber numberwithbool:yes] forkey:kcicontextusesoftwarerenderer]]; filter = [cifilter filterwithname:@"cipixellate" keysandvalues:kciinputimagekey, beginimage, @"inputscale", [nsnumber numberwithfloat:14.0], nil]; ciimage *outputimage = [filter outputimage]; cgimageref cgimg = [context createcgimage:outputimage fromrect:cgrectmake(0, 0, 320, 480)]; uiimage *newimg = [uiimage imagewithcgimage:cgimg];
// new image bigger in size , part cropped :-/
uiimageorientation originalorientation = origim.imageorientation; ciimage *result = [ciimage imagewithcgimage:origim.cgimage]; cicontext *context = [cicontext contextwithoptions:nil]; cifilter *pixel = [cifilter filterwithname:@"cipixellate"]; [pixel setdefaults]; [pixel setvalue:result forkey:@"inputimage"]; [pixel setvalue:[civector vectorwithx:100.0 y:100.0] forkey:kciinputcenterkey]; [pixel setvalue:[nsnumber numberwithfloat:yeslider.value] forkey:kciinputscalekey]; result = [pixel valueforkey:kcioutputimagekey]; cgimageref imgref = [context createcgimage:result fromrect:result.extent]; uiimage *newimage = [uiimage imagewithcgimage:imgref];
in code you’re creating cgimage rect. aren't using .extent
. causes image’s original dimensions lost.
Comments
Post a Comment