iPhone MapView save to Photo Album - iphone

How do I save a MapView to the PhotoAlbum for later attachment to an email created within my iPhone application?

Try this:
UIGraphicsBeginImageContext(map.layer.bounds.size);
[map.layer renderInContext:UIGraphicxGetCurrentContext()];
UIImage *mapImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
And perhaps you should also double-check Google's licensing terms if they allow making and distributing screenshots of the maps.

Related

Unable to convert a PNG image using UIImagePNGRepresentation

I'm writing a function to download a regular PNG file from web server and save it to iPhone Photos album. I don't get any error for my code listed below but UIImagePNGRepresentation doesn't perform the convert at all. All images I got were black. I have to enable "auto-enhanced" under Photos to display those image properly. Any clue what's wrong with my code? Thanks in advance.
UIImage *orgImg = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:#"http://server.com/test.png"]]];
NSData * convertedData = UIImagePNGRepresentation(orgImg);
UIImage * img = [UIImage imageWithData: convertedData];
// Save Image to Photo Album
UIImageWriteToSavedPhotosAlbum(img, self,
#selector(thisImage:hasBeenSavedInPhotoAlbumWithError:usingContextInfo:), nil);
Some more details of these two output images, orgImg and img:
If I pass orgImg to UIImageWriteToSavedPhotosAlbum directly, I did get the same PNG image hosted on the server. However Photos application on my iPhone displays it as a black image because Photos doesn't enhance PNG format automatically.
As for the img I got after using UIImagePNGRepresentation, the image data has been changed by the method, some meta data such as width/height have been removed from the original image. However Photos app on my iPhone still display it as an all black image.
Both images display properly if I copy them into either Safari or email. I didn't get any problem if I use JPEG in the server side either. Just curious why only PNG format doesn't work.

Objective-C - Adding GPS information to a photograph

I am wondering if it is possible to add GPS information to a photograph when saving the item to the camera roll.
The code I currently use to save the image is:
UIImage *theImage = (UIImage *)[info objectForKey: UIImagePickerControllerOriginalImage];
UIImageWriteToSavedPhotosAlbum(theImage, self,
#selector(image:didFinishSavingWithError:contextInfo:), nil);
I am wondering how I can modify the image EXIF data to add the current location, and make it compatible with the 'Places' functionality on the iPhone.
This example: http://caffeinatedcocoa.com/blog/?p=7 explains how to update the date of a photo. Go to CGImageProperties Reference and do the same replacing the key kCGImagePropertyExifDateTimeDigitized of the example with the relevant GPS keys. I haven't try this myself, but sounds like it should work. :)

How to obtain a copied image from the pasteboard?

I have a photo editing app where I want to provide a way for the user to edit photos from the pasteboard. For example the user might copy a photo from his website in Safari and then head over to my app and choose "Open from pasteboard". Kind of like Photoshop does it.
How can I get notified or check if there is a picture or graphic (probably a UIImage) in the pasteboard? And how could I obtain that image?
I needed one for a UIImage and this snippet helped me out.
You can always extract the image out using:
UIImage *image = [UIPasteboard generalPasteboard].image;

Make applications similar to Talking Tom Cat

I want to make an applications similar to Talking Tom Cat, Touch Pets Cats/, Virtual Monkey and the Tap Zoo.
I have knowledge of Iphone basic animation.
I want to know that can i make these apps without OpenGL ,cocos and other gaming environment...
Can i make it by using only basic frameworks...
Well if its related to talking tom then there is no OpenGLES Use... they are simply using images and animate them. using something like this -
aniImage = [[UIImageView alloc] init];
UIImage* opa1 = [UIImage imageNamed:#"o1.png"];
UIImage* opa2 = [UIImage imageNamed:#"o2.png"];
UIImage* opa3 = [UIImage imageNamed:#"o3.png"];
UIImage* opa4 = [UIImage imageNamed:#"o4.png"];
UIImage* opa5 = [UIImage imageNamed:#"o5.png"];
UIImage* opa6 = [UIImage imageNamed:#"o6.png"];
UIImage* opa7 = [UIImage imageNamed:#"o7.png"];
UIImage* opa8 = [UIImage imageNamed:#"o8.png"];
UIImage* opa9 = [UIImage imageNamed:#"o9.png"];
UIImage* opa10 = [UIImage imageNamed:#"o10.png"];
UIImage* opa11 = [UIImage imageNamed:#"o11.png"];
UIImage* opa12 = [UIImage imageNamed:#"o12.png"];
UIImage* opa13 = [UIImage imageNamed:#"o13.png"];
UIImage* opa14 = [UIImage imageNamed:#"o14.png"];
UIImage* opa15 = [UIImage imageNamed:#"o15.png"];
UIImage* opa16 = [UIImage imageNamed:#"o16.png"];
UIImage* opa17 = [UIImage imageNamed:#"o17.png"];
UIImage* opa18 = [UIImage imageNamed:#"o18.png"];
NSArray *imgsArr = [NSArray arrayWithObjects:opa1, opa2, opa3, opa4,
opa5, opa6, opa7, opa8, opa9, opa10, opa11, opa12, opa13, opa14, opa15, opa16, opa17, opa18, nil];
[aniImage setAnimationImages:imagesOpcaity];
[aniImage setAnimationRepeatCount:1.0];
[aniImage setAnimationDuration:0.2];
If you wants to see all the images they are using follow these setps -
1) buy the free version on your iPhone/iPad
2) transfer your purchases on your mac or windows.
3) then drag the ipa file from Library -> Apps to your desktop (just drag the app icon from iTunes to desktop)
4) rename the .ipa file to .zip file
5) extract this zip file.
6) you will get a folder named "Payload" in it.
7) open the .app file (it will open on windows automatically because it is a folder on windows, on mac right click on it and select show package content.
8) in the .app folder you will find a folder which contains all the images used by above function.
Hope it helps
There are 2 approaches
One - make them as 3d Models with animations. The best suited too for this is Unity3d (it brings down development time to a great extent) But the basic version for iPhone to publish costs 400$. I think its worth it.
Two - Make all of them as frame animations. Use either Cocos2d or UIImageView's frames to animate it. You need to dealloc and alloc on the fly when you have too many frames due to which you might hit memory warning. You might think loading on the fly would be costly/intensive but its not as much as you would expect, as iDevices have flash memory on them and we have tried this.
I personally would say use 2nd method if you need just a clone. But with 3d models with animations in them, you get more freedom to add creativity like a 3d camera to look around. So you can poke in the butt and have a different animation for it etc. Also you could have overlay texture and do things like adding tattoos to the 3d model.
You can make Tap Zoo and other by using images or sprite sheets may be on UIButton or enable user interaction for images. but you have to use alot of coding to implement some like that big, it wouldn't be difficult to accomplish it just many lines of code(seriously many more than 100K). So take my advise and learn cocoa2d or quartzcore2d or opengl that way you will not only learn something new but also be able to make nice games. for opengl start up follow this link
http://appstapnet.blogspot.in/2009/04/opengl-es-from-ground-up-part-1-basic.html?m=1

iphone : How to convert webpage(UIWebView) to pdf

i want to convert my webpage(displayed in UIWebView) contents in pdf file.
which can be stored at perticular directory (document dir/any user defined dir).
So later on it can be viewable to user either internet connection not available.
is there any possibilities to perform this functionality.
how can i do this...
Thanking you in advance...
An image might be your best option. See Take snapshot of view / WebView programmatically
To get the image, you'll want to use:
UIGraphicsBeginImageContext(self.bounds.size);
[theView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Then, to save to the Photos Library:
UIImageWriteToSavedPhotosAlbum(viewImage,nil,NULL,NULL);