Create a QQ Avatar with a white border using quztrz2d

Source: Internet
Author: User

 

-(Void) circleheadportrait
{
// 1. Load the source Image
Uiimage * oldimage = [uiimage imagenamed: @ "me"];

// 2. Enable a context of the same size as the image, that is, enable a new image. The size of the new image is the same as that of the original image.
Uigraphicsbeginimagecontextwitexceptions (oldimage. Size, no, 0.0 );

// 3. Obtain the current context
Cgcontextref CTX = uigraphicsgetcurrentcontext ();

// 4. Circle
Cgrect circlerect = cgrectmake (0, 0, oldimage. Size. Width, oldimage. Size. Height );
Cgcontextaddellipseinrect (CTX, circlerect );

// 5. Crop according to the current path shape (Circular). content beyond this shape is not displayed
Cgcontextclip (CTX );

// 6. Drawing
[Oldimage drawinrect: circlerect];

// 7. Obtain the image
Uiimage * newimage = uigraphicsgetimagefromcurrentimagecontext ();

// 8. End
Uigraphicsendimagecontext ();

// 9. Write the file
Nsdata * Data = uiimagepngrepresentation (newimage );
Nsstring * Path = [[nssearchpathfordirectoriesindomains (nsdocumentdirectory, nsuserdomainmask, yes) lastobject] stringbyappendingpathcomponent: @ "new.png"];
[Data writetofile: path atomically: Yes];

// 10. display the image
Self. iconview. Image = newimage;
}

Create a QQ Avatar with a white border using quztrz2d

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.