objective c - UIImage orientation changed when drawing in UIGraphicsBeginImageContext -
i want resize uiimage used below code.
uigraphicsbeginimagecontext(size); [sourceimage drawinrect:cgrectmake(0, 0, size.width, size.height)]; uiimage *destimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext();
above code works fine orientation of destimage changed. don't know how.
source.imageorientation = 3 destimage.imageorientation = 0
can 1 tell me how resize image same orientation sourceimage?
edited:
uiimage *scaleimage = [uiimage imagewithcgimage:destimage.cgimage scale:sourceimage.scale orientation:sourceimage.imageorientation];
edited:
i getting result after resize image.
i have tried above code also. still give me opposite orientation.
resize imageview
calayer *layer; layer=self.view.layer; uigraphicsbeginimagecontext(self.view.bounds.size); cgcontextcliptorect (uigraphicsgetcurrentcontext(),captureframe); //give frame of image here(x,y,width,height) [layer renderincontext:uigraphicsgetcurrentcontext()]; uiimage *screenimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext();
also try below code
uigraphicsbeginimagecontext(self.frame.size); [drawimage.image drawinrect:cgrectmake(0, 0, self.frame.size.width, self.frame.size.height)]; cgcontextsetlinecap(uigraphicsgetcurrentcontext(), kcglinecapround); cgcontextsetlinewidth(uigraphicsgetcurrentcontext(), 3.0); cgcontextsetrgbstrokecolor(uigraphicsgetcurrentcontext(), 0.0, 0.0, 0.0, 1.0); cgcontextstrokepath(uigraphicsgetcurrentcontext()); cgcontextflush(uigraphicsgetcurrentcontext()); drawimage.image = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext();
Comments
Post a Comment