IOS view Blur Background

Source: Internet
Author: User

1 /**2 * Blur Background3  *4 * @param image requires a blurred image5 * @param blur Gaussian blur value6  *7 * @return8  */9-(UIImage *) Blurryimage: (UIImage *) Image withblurlevel: (cgfloat) BlurTen { One     if((Blur <0.0f) || (Blur >1.0f)) { ABlur =0.5f; -     } -      the     intBoxsize = (int) (Blur * -); -Boxsize-= (boxsize%2) +1; -      -Cgimageref img =image. Cgimage; +      - Vimage_buffer Inbuffer, Outbuffer; + Vimage_error Error; A     void*Pixelbuffer; at      -Cgdataproviderref Inprovider =Cgimagegetdataprovider (IMG); -Cfdataref Inbitmapdata =Cgdataprovidercopydata (inprovider); -      -Inbuffer.width =cgimagegetwidth (IMG); -Inbuffer.height =cgimagegetheight (IMG); inInbuffer.rowbytes =Cgimagegetbytesperrow (IMG); -Inbuffer.data = (void*) cfdatagetbyteptr (inbitmapdata); to      +Pixelbuffer = malloc (Cgimagegetbytesperrow (IMG) *cgimagegetheight (IMG)); -      theOutbuffer.data =Pixelbuffer; *Outbuffer.width =cgimagegetwidth (IMG); $Outbuffer.height =cgimagegetheight (IMG);Panax NotoginsengOutbuffer.rowbytes =Cgimagegetbytesperrow (IMG); -      theError = vimageboxconvolve_argb8888 (&inbuffer, &outbuffer, NULL,0,0, Boxsize, Boxsize, NULL, kvimageedgeextend); +      ACgcolorspaceref ColorSpace =Cgcolorspacecreatedevicergb (); theCgcontextref CTX = cgbitmapcontextcreate (Outbuffer.data, Outbuffer.width, Outbuffer.height,8, Outbuffer.rowbytes, ColorSpace, Cgimagegetbitmapinfo (image. Cgimage)); +      -Cgimageref Imageref =cgbitmapcontextcreateimage (CTX); $UIImage *returnimage =[UIImage imagewithcgimage:imageref]; $      -     // Clean Up - cgcontextrelease (CTX); the cgcolorspacerelease (colorspace); -     Wuyi Free (pixelbuffer); the cfrelease (inbitmapdata); -      Wu cgcolorspacerelease (colorspace); - cgimagerelease (imageref); About      $     returnReturnimage; -}

IOS view Blur Background

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.