Turn image upside down (Quartz 2D)

Discussion in 'iOS Programming' started by xArtx, Jul 15, 2012.

  1. xArtx macrumors 6502a

    Mar 30, 2012
    Hi Guys,
    I'm using this code to draw an image:

        UIImage *myImage = [UIImage imageNamed:@"Sun.png"]; // sun in sky
        CGPoint imagePoint = CGPointMake(30, 266);
        [myImage drawAtPoint:imagePoint];
    How can I turn it upside down without providing a different source image?
    I would also like to flip it vertically.
    Thanks, Art.
  2. ArtOfWarfare macrumors G3


    Nov 26, 2007
    Hi, I was scanning the Apple docs hoping to find a useful specific part to read, but instead I found this:

    CGContextScaleCTM(graphicsContext, 1.0, -1.0);
    That should horizontally flip your image... I think it'll also move it downwards, so you'll need to translate it upwards by one picture height.

    Here's the apple doc I found that code excerpt in:
  3. xArtx thread starter macrumors 6502a

    Mar 30, 2012
    Found this which works:
    UIImage* flippedImage = [UIImage imageWithCGImage:myImage.CGImage  scale:1.0 orientation: UIImageOrientationDown];
    Flips horizontal & vertical :)
    Goes after the first line posted above.

Share This Page