Tutorial :How to save iphone screen shot as jpeg image?


I am working on an app where I need to save a part of iphone's screen shot as JPEG and then send this through email. The part of screen has some text labels, fields etc. Any ideas please on how can I save part of screen as JPEG (I am a newbie therefore any help/sample code is highly appreciated)


The following code will save the contents of a view to the user's photo library. You should be able to modify it to be able to email the file instead.

  CGRect myRect = [myView bounds];    UIGraphicsBeginImageContext(myRect.size);      CGContextRef ctx = UIGraphicsGetCurrentContext();    [[UIColor blackColor] set];    CGContextFillRect(ctx, myRect);      [myView.layer renderInContext:ctx];      UIImage *image1 = UIGraphicsGetImageFromCurrentImageContext();      // Replace the following line with code that emails the image    UIImageWriteToSavedPhotosAlbum(image1, nil, nil, nil);    UIGraphicsEndImageContext();  


From http://blogs.zdnet.com/mobile-gadgeteer/?p=1278:

When you are on a screen that you want to capture, press and hold the Home button and then press the the power/sleep button. Your screen shot will then appear photo gallery on your iPhone where you can send it or sync it as needed.


You will need a QuartzCore library.

See this one: http://www.iphonedevsdk.com/forum/iphone-sdk-development/2353-possible-make-screenshot-programmatically-2.html

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »