The way iOS is synthesized, I know two other kinds:
1: Direct synthesis using uiimage
Method: The picture is drawn to the context by the context to which it will be synthesized, and then the resultant picture
-(uiimage*) Ntesatcoverlaywith: (uiimage*) overlayimage{
Uigraphicsbeginimagecontext (self.size);
[Self Drawatpoint:cgpointzero];
[OverlayImage drawinrect:cgrectmake (0, 0, self.size.width, self.size.height) Blendmode:kcgblendmodenormal alpha:0. 9999999];
UIImage *combinedimage = Uigraphicsgetimagefromcurrentimagecontext ();
Uigraphicsendimagecontext ();
return combinedimage;
}
2: Through the UIView
Method: Load the picture onto a uiview and then generate the picture through UIView.
-(UIImage *) Imagefromview: (UIView *) View {
We need to size the graphics context according to the device scale
CGFloat scale = [[UIScreen mainscreen] scale];
Cgsize pageSize = view.frame.size;
Cgcolorspaceref colorspace = Cgcolorspacecreatedevicergb ();
Cgcontextref context = Cgbitmapcontextcreate (NULL,
Pagesize.width*scale,
Pagesize.height*scale,
8,/* bits per component*/
Pagesize.width*scale * 4,/* bytes per row */
ColorSpace,
Kcgimagealphapremultipliedfirst | Kcgbitmapbyteorderdefault);
Cgcolorspacerelease (ColorSpace);
Cgcontextcliptorect (context, CGRectMake (0, 0, Pagesize.width*scale, Pagesize.height*scale));
CGCONTEXTSCALECTM (context, scale, scale);
[View.layer Renderincontext:context];
Cgimageref image = Cgbitmapcontextcreateimage (context);
Cgcontextrelease (context);
UIImage *destimaage = [UIImage imagewithcgimage:image scale:1 Orientation:uiimageorientationdown | Uiimageorientationdownmirrored];
Cgimagerelease (image);
return destimaage;
}
This article is from the "share your achievements in the future" blog, please be sure to keep this source http://89092706.blog.51cto.com/9265997/1539140