iphone, when saving image with "renderInContext" to device, the image is blurry? - iphone

I'm using this code to render an image from view.
Then i am saving it to photo album.
The image is blurry?
Why? Is there a solution?
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Tnx all.

You are propably using a retina device,
Change the following
UIGraphicsBeginImageContext(self.view.bounds.size)
to
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);

Related

Taking a screenshot in-app then putting it in a UIImageView does so at normal resolution

After zooming the iOS simulator up to 100%, i've noticed that my icons which are made by the app through taking a 'screenshot' of a view using this code are in normal resolution, whereas everything else appears to be in retina resolution:
UIGraphicsBeginImageContext(rect.size);
[object.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Any ideas how to make it be in retina resolution?
UIGraphicsBeginImageContext() is not Retina display-aware.
On iOS 4, you'll need to use UIGraphicsBeginImageContextWithOptions() instead, passing 0 as the last argument to have iOS automatically scale it based on the device's screen resolution:
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
[object.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

HTMLto texture on iPhone

Is there a way to grab the pixels from an UIWebView and render it to an opengl texture?
I don't know what it takes to load an opengl texture. But this will convert the data from a view into a jpeg.
UIGraphicsBeginImageContext(self.bounds.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
sorry for the half answer. hope someone can take it from here...

iPhone Screenshots

I've been using UIGetScreenImage() to get a screenshot of a UIImagePickerController. Basically I use the camera overlay and then when I take the screenshot, I have the image that the camera preview had been showing and my overlay on there too, which is exactly what I need.
Now UIGetScreenImage() has been banned, I've not been able to find a way to do this. It just shows black for the camera.
Edit: all of my other views are showing absolutely fine, just not the actual camera preview. Any ideas??!?!?
Here's the code I am using at the moment.
UIGraphicsBeginImageContext(picker.view.bounds.size);
[picker.view.layer renderInContext:UIGraphicsGetCurrentContext()];
CGContextDrawImage(context, bounds, camView.CGImage);
UIImage* screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(screenImage, nil, nil, nil);
UIGraphicsEndImageContext();
Any ideas how I can get the overlay + the camera image?
Thanks!
This is slightly different than yours.
CGRect screenRect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(screenRect.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *sShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum (sShot, nil, nil, nil);
Does that work?
If not, you might want to try asking over at iphonedevsdk.com since they specialize in all things iPhone.
Have them take a picture. Then overlay your image on top of it.
Create a UIImage from two other UIImages on the iPhone

scale image of size 1600*1200

I am developing image size based iphone application. selecting two photos of size 1600*1200 from photo library and merging of both to single image and save to same library. Again if i check the image size it shows 600* 800. How to get original size(1600*1200) of created New photo(600*800).
Thanks in advance.
Check the UIImagePickerControllerDelegate Protocol Reference.
The info NSDictionary of the imagePickerController:didFinishPickingMediaWithInfo: method contains the original image.
Solved as follows.
UIView *bgView = [[UIView alloc] initwithFrame:CGRectMake(0,0,1600,1200)];
UIGraphicsBeginImageContext(tempView.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage,self,nil,nil);
Thanks for all your support to solve the issue.

iphone SDK: How to implement a signature capture?

How can I capture a users signature? The idea is that the user will use their fingers to draw their signature in a box. Part of the saving process will be to write this image to their Photos folder.
I think this will do it.
http://www.ipodtouchfans.com/forums/showthread.php?t=132024
After that, I think the ability to save a screen capture will do the job.
UIGraphicsBeginImageContext(self.view.bounds.size); //self.view.window.frame.size
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);