i want to convert UIImageView to UIImage or in PDF also, is it possible?? - ios5

i have taken an UIImageView on top of it taken some labels now i want to convert this UIImageView to UIImage or in PDF also, is it possible??

By your question , it seems you want to take a screenshot of your view and save it as an image or pdf.
You can take Screenshot of view and save it in photo Gallery using following code.
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShotimage = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(screenShotimage, nil, nil, nil);
UIGraphicsEndImageContext();

Related

why the image become zoom while converting view to image?

I have uiview and i want to convert that view to image which is working quite well but when i pressed the home button of iphone and run the app again the image become zoom in .Here is my code to converting view to image.
- (UIImage *)captureView {
CGRect rect = [myview bounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[myview.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
checkImage.image = [self captureView];
here this code is not wrong but you used some other object instead of whole view . i don't know but try to use that view bounds in which that whole Image display.. See my answer same like your this answer from this bellow link..
how to capture uiview top uiview
Also try with self.view instead of myView in your code.
add this code instead of your checkImage.image = [self captureView]; line..
UIImageView *imgTempHeader = [[UIImageView alloc]initWithImage:[self captureView]];
imgTempHeader.frame = self.view.frame;
[self.view addSubview:imgTempHeader];
[self.view bringSubviewToFront:imgTempHeader];
You should be creating the context in a way which uses the scale of the device:
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
Then when you display the image in the image view ensure that the content mode is set to prevent scaling.
My experience is with setting up imageViews in IB. I assume checkImage is an instance of UIImageView?
If you were displaying an image in a UIImageView and had only set the view mode to center in interface builder it would appear zoomed in if the image was large.
Have a look at this way to process your image first:
UIImage *newImage = [[UIImage alloc] initWithCGImage:myCGImageRef scale:myZoomSCale orientation:UIImageOrientationDown];
Of course you will need to give it a CGImageRef for your image. Over to you or somebody else for that.

Is possible PrintScreen or save in an image some part of the screen?

Is it possible? I need save the sreen and send from iPad to a WebService... Concretly the problem is that i want simulate a sign in the screen and later save this sign in a NSData and send by email.
Some idea?
thanks for all!
Best regards!
UIView *view = ...; // Get root view of current view controller
UIGraphicsBeginImageContext(view.bounds.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *imageData = UIImagePNGRepresentation(viewImage);

How to convert contents of a hidden webview to uiimage?

In my application, I converted the contents loaded in a UIWebView to a UIImage and had shown it in an UIImageView.
Now what I want to do is have a hidden webview load contents from an URL, and then convert its contents into a UIImage.
Can any body please suggest a method?
#import <QuartzCore/QuartzCore.h>
UIGraphicsBeginImageContext(yourWebView.bounds.size);
[yourWebView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Capturing image storing in UIimage view showing landscape direction

I wrote the code for camara application. The view having one button and one UIimageview. When I click on camera, camera will open after capturing image and when I click on use button it is showing some part only in the UIimageview that too in landscape direction.
CGSize size=CGSizeMake(editView.bounds.size.width,editView.bounds.size.height);
UIGraphicsBeginImageContext(size);
[editView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImageCaptureSend = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImageCapture, nil, nil, nil);

iphone screenshot specific area

I have a View including a Toolbar and a WebView
UIVIEW
UIToolbar
UIWebview
Now i like to make a screenshot ONLY from the WebView with:
UIGraphicsBeginImageContext(articleWebView.window.bounds.size);
[articleWebView.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
But always ImageCapture starts from the TOP of the Screen.
So it includes the Toolbar (even 20 empty pixel at the top from the Statusbar)
How can I just capture the Image thats actual in my UIWebView?
Thanks Chris
Your UIWebView is backed by its own layer, so you should be able to just grab the currently displayed contents for it:
UIGraphicsBeginImageContext(articleWebView.bounds.size);
[articleWebView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();