Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIGraphicsBeginImageContext with parameters

I am taking a screenshot in my application. I am able to take the screenshot.

Now I want to take the screenshot by specifying the x and y coordinate. Is that possible?

UIGraphicsBeginImageContext( self.view.bounds.size );
[self.view.layer renderInContext:UIGraphicsGetCurrentContext(  )];
UIImage* aImage = UIGraphicsGetImageFromCurrentImageContext(  );
like image 313
user198725878 Avatar asked Nov 16 '10 13:11

user198725878


1 Answers

UIGraphicsBeginImageContext(self.view.bounds.size);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(c, 0, -40);    // <-- shift everything up by 40px when drawing.
[self.view.layer renderInContext:c];
UIImage* viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
like image 87
kennytm Avatar answered Oct 10 '22 22:10

kennytm