Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Hi Guys,
I'm using this code to draw an image:

Code:
    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.
 
Hi, I was scanning the Apple docs hoping to find a useful specific part to read, but instead I found this:

Code:
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:
http://developer.apple.com/library/ios/documentation/2ddrawing/conceptual/drawingprintingios/graphicsdrawingoverview/graphicsdrawingoverview.html
 
Found this which works:
Code:
UIImage* flippedImage = [UIImage imageWithCGImage:myImage.CGImage  scale:1.0 orientation: UIImageOrientationDown];
Flips horizontal & vertical :)
Goes after the first line posted above.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.