static void Addroundedrecttopath (Cgcontextref context, CGRect rect, float ovalwidth, float ovalheight) {float FW, FH; Ovalwidth = = 0 | | Ovalheight = = 0) {cgcontextaddrect (context, rect); return;} Cgcontextsavegstate (context); CGCONTEXTTRANSLATECTM (Context, Cgrectgetminx (rect), Cgrectgetminy (rect)); CGCONTEXTSCALECTM (context, ovalwidth, ovalheight); FW = Cgrectgetwidth (rect)/ovalwidth; FH = cgrectgetheight (rect)/ovalheight; Cgcontextmovetopoint (Context, FW, FH/2); Start at lower right corner cgcontextaddarctopoint (context, FW, FH, FW/2, FH, 1); Top Right corner cgcontextaddarctopoint (context, 0, FH, 0, FH/2, 1); Top left corner cgcontextaddarctopoint (context, 0, 0, FW/2, 0, 1); Lower left corner Cgcontextaddarctopoint (context, FW, 0, FW, FH/2, 1); Lower right cgcontextclosepath (context); Cgcontextrestoregstate (context);} + (ID) createroundedrectimage: (uiimage*) Image size: (cgsize) size{//the size of cgcontextref int w = size.width; int h = s Ize.height; UiImage *img = image; Cgcolorspaceref colorspace = Cgcolorspacecreatedevicergb (); Cgcontextref context = Cgbitmapcontextcreate (NULL, W, H, 8, 4 * W, colorspace, Kcgimagealphapremultipliedfirst); CGRect rect = CGRectMake (0, 0, W, h); Cgcontextbeginpath (context); Addroundedrecttopath (Context, rect, 10, 10); Cgcontextclosepath (context); Cgcontextclip (context); Cgcontextdrawimage (context, CGRectMake (0, 0, W, h), IMG. Cgimage); Cgimageref imagemasked = cgbitmapcontextcreateimage (context); Cgcontextrelease (context); Cgcolorspacerelease (ColorSpace); return [UIImage imagewithcgimage:imagemasked];} Call Createroundedrectimage directly .... return fillet picture fillet size self-modify cgcontextaddarctopoint ....
Cut a picture into a fillet code