0

there are many threads about how to save a view as an image. And all of them give the same answer:

CGRect rect = [myView bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,[[UIScreen mainScreen] scale]);
CGContextRef context = UIGraphicsGetCurrentContext();
[myView.layer renderInContext:context];   
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

my problem is that I have a view that contains several joined imageViews that contain images. I want to save that "holder" view in a size that corresponds to the size of images residing inside it. So if i have 2 images 400x400 side by side, I'd like to save 400x800 image, regardless that they are displayed lets say 30x60.

Plus the above code only captures what's on the screen and leaves out the rest. For instance if i wanted to get the entire scrollview with its content size, it's not possible.

any ideas?

Au Ris
  • 4,541
  • 2
  • 26
  • 53

1 Answers1

0

If you want to get an image of the entire contentSize of a UIScrollView, take a look at this.

Community
  • 1
  • 1
Mat
  • 7,613
  • 4
  • 40
  • 56
  • Thanks. But your posted thread does not solve the problem. UIGraphicsGetCurrentContext() only captures what's on the screen. The only way to make use of it is to fit the view to screen, but then the resolution degrades. I need an alternative. – Au Ris Oct 25 '12 at 09:57
  • That snippet captures the whole content of the scrollview and save it in UIImage. It seems that you're capturing just the bounds of your view not the entire contentSize of the scrollview. – Mat Oct 25 '12 at 10:07
  • I perfectly understand that. That's why I am asking the above question. If I set the rect size lets say to scrollview.contentSize it will indeed make an image of that size, but everything outside the bounds will be white space. I can't emphasize enough that I am looking for an alternative, because UIGraphicsGetCurrentContext() gets only what's on the screen. – Au Ris Oct 25 '12 at 10:20
  • OK. the strange this is this: If i render uiscrollview with the dimensions of its contentSize, it cuts the content that is outside the screen and makes the rest of the image blank. If I put my contents to a uiview and render that, it does the job properly. Still however i need to find a way how to save the images in their full quality... – Au Ris Oct 25 '12 at 10:39