cgcontextdrawimage

rotate image using CGContextDrawImage

夙愿已清 提交于 2019-11-28 12:08:42
How can I rotate an image drawn by CGContextDrawImage() at its center? In drawRect: CGContextSaveGState(c); rect = CGRectOffset(rect, -rect.size.width / 2, -rect.size.height / 2); CGContextRotateCTM(c, angle); CGContextDrawImage(c, rect, doodad.CGImage); CGContextRotateCTM(c, -angle); CGContextTranslateCTM(c, pt.x, pt.y); prevRect = rect; CGContextRestoreGState(c); I draw the image at the origin, and rotate it at its center, then translate to where it should be drawn. Not working. The thing to remember about coordinate transformations—well, one of the things to remember—is that you are not

CGContextDrawImage draws image upside down when passed UIImage.CGImage

百般思念 提交于 2019-11-26 13:56:06
Does anyone know why CGContextDrawImage would be drawing my image upside down? I am loading an image in from my application: UIImage *image = [UIImage imageNamed:@"testImage.png"]; And then simply asking core graphics to draw it to my context: CGContextDrawImage(context, CGRectMake(0, 0, 145, 15), image.CGImage); It renders in the right place, and dimensions, but the image is upside down. I must be missing something really obvious here? Kendall Helmstetter Gelner Instead of CGContextDrawImage(context, CGRectMake(0, 0, 145, 15), image.CGImage); Use [image drawInRect:CGRectMake(0, 0, 145, 15)];

CGContextDrawImage draws image upside down when passed UIImage.CGImage

半城伤御伤魂 提交于 2019-11-26 03:46:53
问题 Does anyone know why CGContextDrawImage would be drawing my image upside down? I am loading an image in from my application: UIImage *image = [UIImage imageNamed:@\"testImage.png\"]; And then simply asking core graphics to draw it to my context: CGContextDrawImage(context, CGRectMake(0, 0, 145, 15), image.CGImage); It renders in the right place, and dimensions, but the image is upside down. I must be missing something really obvious here? 回答1: Instead of CGContextDrawImage(context, CGRectMake