i have a UIView having 3 UITableView and need to take screen shot. But problem is invisible part of the 3 tables . Can anyone help to find a way to take screen shot of the whole view including complete scrolled contents of the tables.
This helps get the contents of a layer (ie. and thus a UIView)
UIGraphicsBeginImageContext(tableView.frame.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[tableView.layer renderInContext:ctx];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Related
Hi am a noob at PDF generation and currently am displaying a 3d bar charts in my application in glview which is in side a uiview. Now i want to generate a PDF document from the uiview which contains a text view and a glview. Am able to generate a PDF from text but where as GL View am unable to proceed.even i tried for a possibility over the net but unable to get any info regarding this.Can someone help me by providing the solution whether this can be possible or not.Thanks in Advance
You can ask any UIView to give you an image (which might be a start) via something like:
- (UIImage *) imageRepresentation {
// render myself (or more correctly, my layer) to an image
UIGraphicsBeginImageContext(self.bounds.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetShouldSmoothFonts(context, false);
CGContextSetShouldAntialias(context, false);
[self drawLayer:self.layer inContext:context];
[self.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
After that, you might be able to get a PDF representation of it, or investigate calls like CGPDFDocumentCreateWithURL to construct one yourself from the image.
You can use CoreGraphic's PDF-APIs to creating and drawing to a PDF.
See Apple's guide for more details.
I am perfoming image sequences animation is on main thread.
At the same time i want to take snapshot of device screen in back ground.
And by using that snapshots i want make video..
Thanks,
Keyur Prajapati
For taking the screenshots while running the image animations
use
[self.view.layer.presentationLayer renderInContext:UIGraphicsGetCurrentContext()];
instead of
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
it will take screenshots while runing animations
iOS uses Core Animation as the rendering system. Each UIView is backed by a CALayer. Each visible layer tree is backed by a presentation tree. The layer tree contains the object model values for each layer, i.e., values you set when you assign a value to a layer property (A and B). The presentation tree contains the values that are currently being presented to the user as an animation takes place (interpolated values between A and B).
If you're doing it in CoreAnimation you can render the layer contents into a bitmap using -renderInContext:. Have a look at Matt Longs Tutorial. It's for Objective-C on the Mac, but it can be easily converted for use on the iPhone.
Create one another thread where you can do this:
//Create rect portion for image if full screen then 320X480
CGRect contextRect = CGRectMake(0, 0, 320, 480);
// this is whate you need
UIGraphicsBeginImageContext(contextRect.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage* viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
viewImage is the image which you needed.
You can write this code in function which can be called timely bases like per 5 seconds or according to your requirements.
Hope this is what you needed.
i load data in a tableview, each row have a simple picture 500x300px that go resize to size of cell.
Is possible resize the images?
tableview.m
NSString *filePath = [[NSBundle mainBundle] pathForResource:receip.image ofType:#"jpg"];
UIImage *image = [UIImage imageWithContentsOfFile:filePath];
cell.imageView.image = image;
I assume you mean resize them before putting them in the cell to improve performance?
You can do this with core graphics as follows:
//define desired size
CGSize size = CGSizeMake(100.0f, 100.0f);
//create drawing context
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0f);
//draw image at new size
[image drawInRect:CGRectMake(0.0f, 0.0f, size.width, size.height)];
//capture resultant image
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Be warned though that is a computationally expensive task. You'll probably want to resize all your images in advance, possibly on a background thread, and store the resized versions in an array. You definitely do not want to stick the code above in your cellForRowAtIndexPath method, or your table scrolling performance will be diabolical.
If those images come from an external source (say the web). It's better to first cache the original file and then (like explained by #Nick Lockwood) resize them (remember retina displays need twice the width / height for hi-res displaying). And after that process is complete you can send a signal that the "download" is complete and carry on showing the UITableView
If you already have the images in your app bundle I suggest you make a thumb version of that and add it to your bundle. For better performance o'course.
I am making an app that adds a picture frame to a photo.I would like to know how to have my Save button save both Images (the photo, and the frame) as one Image.Right now it only saves one of the images.
In interface builder I have the save action saving the image that is loaded into an ImageView, with the frame ImageView overlaying that image.
I'd like to merge the two photos as one, so the save action can save the image with the frame.
Thanks!
In this may need to use the masking in the iphone where the unnecessary thing of the image is automatically remove and attach with the frame.
I think this help to implement best for the your applications
So you can refer the following link for Download and tutorial and Source also.
Reference link
You need to do some drawing using Core Graphics. This code should do what you want, possibly with some tweaks to the rectangles/sizes:
UIGraphicsBeginImageContext(image.size);
[image drawRect:CGRectMake(0, 0, image.size.width, image.size.height);
[frameImage drawRect:CGRectMake(0, 0, image.size.width, image.size.height);
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
I'm working on an app in which I am looking to take a screenshot of the map to record where a person was when the action was performed, which is then sent in a report back to the server. I do not want the person to see the map pop up while the screenshot is being taken and the user should be oblivious of the screenshot until they review the report.
I have looked at the following question:
how to take a screen shot from a mapview
But they are making the map visible in order to take the screenshot.
Thank you for your time.
If understand correctly, you have a view somewhere and you do not want it on screen, but you want to capture an image of it.
UIGraphicsBeginImageContextWithOptions(mapView.bounds.size,mapView.alpha, mapView.contentScaleFactor);
CGContextRef context = UIGraphicsGetCurrentContext();
mapView.backgroundColor = [UIColor whiteColor];
[mapView.layer renderInContext:context];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();