Uigraphicsbeginimagecontext
First explain the difference between uigraphicsbeginimagecontextwithoptions and Uigraphicsbeginimagecontext:
1:uigraphicsbeginimagecontext (cgsize size)
The size of the parameter is the newly created bitmap context. It is also the size of the graph returned by the Uigraphicsgetimagefromcurrentimagecontext function.
The function is the same as the function of uigraphicsbeginimagecontextwithoptions, quite with the uigraphicsbeginimagecontextwithoptions The opaque parameter is noand the scalefactor is 1.0.
2 uigraphicsbeginimagecontextwithoptions
The function prototypes are:
void Uigraphicsbeginimagecontextwithoptions (cgsize size, BOOL opaque, cgfloat scale);
size--with Uigraphicsbeginimagecontext
opaque-Transparent switch, if the graphic is not transparent at all, set to Yes to optimize the storage of the bitmap.
scale-– Scaling Factor
In particular, when the zoom factor is 0.0, the picture is not blurred
Screen Cutting
-(UIImage *) Capturescrollview: (Uiscrollview *) scrollview{
uiimage* image = Nil;
Uigraphicsbeginimagecontext (scrollview.contentsize); Default
Uigraphicsbeginimagecontextwithoptions (Scrollview.contentsize, NO, 0.0);
{
Cgpoint savedcontentoffset = Scrollview.contentoffset;
CGRect savedframe = scrollview.frame;
Scrollview.contentoffset = Cgpointzero;
Scrollview.frame = CGRectMake (0, 0, scrollView.contentSize.width, scrollView.contentSize.height);
[Scrollview.layer Renderincontext:uigraphicsgetcurrentcontext ()];
Image = Uigraphicsgetimagefromcurrentimagecontext ();
Scrollview.contentoffset = Savedcontentoffset;
Scrollview.frame = Savedframe;
}
Uigraphicsendimagecontext ();
if (image = nil) {
return image;
}
return nil;
}
Perfect solution ScrollView screenshot image Blur