3

I am using the following code to capture a UIView as a UIImage and save it in Docs Dir.

- (UIImage *) imageWithView:(UIView *)view
{
    UIGraphicsBeginImageContext(view.bounds.size);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return img;
}

The UIImage is successfully saved. However the resolution is very poor. See the image below for reference. How do I make sure the resolution is retained as per the original image?enter image description here

ScarletWitch
  • 522
  • 6
  • 23
  • Take a look at http://stackoverflow.com/questions/11603212/uigraphicsbeginimagecontext-must-be-retina-aware – anticyclope Aug 14 '13 at 10:29
  • 1
    I got your point. But when i added it along with the previous code. Its not working. Can you suggest where shall I add it? – ScarletWitch Aug 14 '13 at 10:36
  • check my answer from this link http://stackoverflow.com/questions/14049796/howe-to-capture-uiview-top-uiview/14049828#14049862 – Paras Joshi Aug 14 '13 at 10:36

1 Answers1

0

Capture the image of Entire view using below code :-

 UIGraphicsBeginImageContext(view.frame.size); 
Rushabh
  • 3,208
  • 5
  • 28
  • 51
Ganapathy
  • 4,594
  • 5
  • 23
  • 41