Sunday, June 19, 2011

Vertical flip in CGontextRef.

Vertical Flip- which means top to down.

If you try to draw an image on CGContextRef , it will appear upside down, you will have to apply transformation on it set it right.Make sure you add QuartzCore.
 #import


1. Drawing an image on CGContextRef without transformation

CGContextRef context=UIGraphicsGetCurrentContext();
CGContextDrawImage(context, CGRectMake(0, 0, 768, 1024), [UIImage imageNamed:@"1.jpg"].CGImage);













2. Drawing an image on CGContextRef with transformation of vertical flip

CGContextRef context=UIGraphicsGetCurrentContext();
CGAffineTransform flipTransform = CGAffineTransformMake( 1, 0, 0, -1, 0, self.frame.size.height);
CGContextConcatCTM(context, flipTransform);
CGContextDrawImage(context, CGRectMake(0, 0, 768, 1024), [UIImage imageNamed:@"1.jpg"].CGImage);









For horizontal flip, you can read this article : LINK

1 comment:


  1. Its very interesting post, good job

    Videocon Telecom has slashed the National Roaming rates effective 1st May 2015 as per the TRAI’s guidelines.The drop in tariff is to the extent of 75% on Local and National SMS; 40% on Incoming calls; and 23% & 20% on STD & Local calls resp while roaming.

    ReplyDelete