ios - Why is my image upside down after using CGContextSetFillColorWithColor -


i trying apply color fill mkannotation. found code pretty works reason filled image upside down after applying fill it.

here current code running on map pin.

cgrect rect = cgrectmake(0, 0, self.image.size.width, self.image.size.height);     uigraphicsbeginimagecontext(self.image.size);     cgcontextref context = uigraphicsgetcurrentcontext();     cgcontextcliptomask(context, rect, self.image.cgimage);     cgcontextsetfillcolorwithcolor(context, [[uicolor graycolor] cgcolor]);     cgcontextfillrect(context, rect);     cgcontextrotatectm(context, 90);     uiimage *img = uigraphicsgetimagefromcurrentimagecontext();     uigraphicsendimagecontext();      uiimage *flippedimage = [uiimage imagewithcgimage:img.cgimage                                                 scale:1.0 orientation:self.image.imageorientation];      self.image = flippedimage; 

here pins after code runs.

http://d.pr/i/uapu

i thinking if applied current image orientation flippedimage trick did not work. tried setting self.image = img; , removing flippedimage var result still same.

cgcontext coordinate system flipped vertically in regard uiview coordinate system. flip this: cgcontexttranslatectm(ctx, 0, imageheight);, cgcontextscalectm(ctx, 1, -1);


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -