IOS Image obfuscation------Direct code copy is available to mark

Source: Internet
Author: User

1.

UIImage *imag = [UIImage imagenamed:@ "img"];

/* --------------------use coreimg---------------------------* /

//Ciimage

ciimage *ciimg = [[ciimage alloc] initwithimage: imag];    

//Cifilter

cifilter *blurfilter = [cifilter filterwithname:@ "Cigaussianblur"];

// can output the degree of blur of the setting

NSLog(@ "%@", [blurfilter attributes]);

// You can set the degree of blur based on the previous step

[Blurfilter setValue:@ (forkey) :@ "Inputradius"];

// image input Filter

[Blurfilter setValue: ciimg forkey:kciinputimagekey];

// push-piece output

ciimage *outputimg = [Blurfilter valueforkey:kcioutputimagekey];

//Cicontext

Cicontext * context = [cicontext contextwithoptions:nil];

// get cgimage handle

cgimageref outimgref = [Context createcgimage: outputimg fromrect: [outputimg extent]] ;

//h get to the last picture

UIImage *blurimg = [UIImage imagewithcgimage: outimgref];

// release handle

cgimagerelease(outimgref);

Finally get the blurred picture blurimg

The second Kind

    /* ___________________  Uiimage+imageeffects.h ________________________________ */

UIImage *sourimg = [UIImage imagenamed:@ "img"];

UIImage *blurimg = [sourimg Blurimagewithradius:];

Third Kind Uivisualeffectview

   uiscrollview *SC = [[ uiscrollview alloc Initwithframe:self. View. Bounds

uiimageview *imgview = [[uiimageview alloc] initwithframe:cgrectmake( 0, 0, + )];

Imgview. image = imag;

[SC addsubview: Imgview];

SC.contentsize = Imgview. Bounds. Size;

[self. View addsubview: sc];

uivisualeffectview *effectview = [[uivisualeffectview alloc] initwitheffect: [ Uiblureffect effectwithstyle:uiblureffectstyleextralight]];

Effectview. frame = cgrectmake(0, N, + );

[self. View addsubview: Effectview];

UILabel *lable = [[UILabel alloc] initwithframe: Effectview. Bounds];

Lable. text = @ " blurred background ";

Lable. font = [uifont systemfontofsize:];

Lable. textalignment = nstextalignmentcenter;

// Add Fuzzy sub effictview using --uivibrancyeffect and need to be consistent with the parent class

uivisualeffectview *subeffectview = [[uivisualeffectview alloc] initwitheffect: [ Uivibrancyeffect effectforblureffect:(uiblureffect *) Effectview. Effect]];

Subeffectview. frame = Effectview. Bounds;

// Add sub-blurred View to effectview contenctview to be effective

[Effectview. contentview addsubview: Subeffectview];

[Subeffectview. contentview addsubview: lable];

IOS Image obfuscation------Direct code copy is available for tagging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.