iphone - Rotate UIImage custom degree -


i want rotate uiimage (not uiimageview) in custom degree followed this post didn't work me.

anyone can help? thanks.

update: code below of job, lose of image after rotating it:

enter image description here

what should change right? (btw yellow color in screenshots uiimageview bg)

- (uiimage *) rotate: (uiimage *) image {     double angle = 20;     cgsize s = {image.size.width, image.size.height};     uigraphicsbeginimagecontext(s);     cgcontextref ctx = uigraphicsgetcurrentcontext();     cgcontexttranslatectm(ctx, 0,image.size.height);     cgcontextscalectm(ctx, 1.0, -1.0);      cgcontextrotatectm(ctx, 2*m_pi*angle/360);     cgcontextdrawimage(ctx,cgrectmake(0,0,image.size.width, image.size.height),image.cgimage);     uiimage *newimage = uigraphicsgetimagefromcurrentimagecontext();     uigraphicsendimagecontext();     return newimage;  } 

this method return image on angle of rotate

#pragma mark - #pragma mark rotate image   - (uiimage *)scaleandrotateimage:(uiimage *)image  {       cgimageref imgref = image.cgimage;      cgfloat width = cgimagegetwidth(imgref);     cgfloat height = cgimagegetheight(imgref);      cgaffinetransform transform = cgaffinetransformidentity;     cgrect bounds = cgrectmake(0, 0, width, height);      cgfloat boundheight;      boundheight = bounds.size.height;       bounds.size.height = bounds.size.width;      bounds.size.width = boundheight;     transform = cgaffinetransformmakescale(-1.0, 1.0);     transform = cgaffinetransformrotate(transform, m_pi / 2.0); //use angle/360 *mpi      uigraphicsbeginimagecontext(bounds.size);        cgcontextref context = uigraphicsgetcurrentcontext();        cgcontextconcatctm(context, transform);      cgcontextdrawimage(context, cgrectmake(0, 0, width, height), imgref);     uiimage *imagecopy = uigraphicsgetimagefromcurrentimagecontext();     uigraphicsendimagecontext();      return imagecopy;     } 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -