Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 03-01-2011, 06:28 AM   #7 (permalink)
app2011
Registered Member
 
Join Date: Feb 2011
Posts: 7
app2011 is on a distinguished road
Thumbs up dowloading an image from web

Quote:
Originally Posted by wode211 View Post
anyone knows ?
1. make a text field to obtain url of image . You can get the url through this piece of code

- (void)webViewDidStartLoadUIWebView *)webView
{
url1 = [webView.request URL];
urlField.text = [url absoluteString];
}
2. make proper connection of delegate of UIWebView in file's owner.
3. make button to download the image!! and method in which u can write!!




url = [webView.request URL];
NSLog(@"url recieved: %@", url);
NSLog(@"Downloading...");
// Get an image from the URL below
UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:url]];
//UIImage *image = [[UIImage alloc] init];
NSLog(@"%f,%f",image.size.width,image.size.height) ;
// Let's save the file into Document folder.
// You can also change this to your desktop for testing. (e.g. /Users/kiichi/Desktop/)
NSString *deskTopDir = @"/Users/gauravmurghai/Desktop";
//NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDire ctory, NSUserDomainMask, YES) objectAtIndex:0];
// If you go to the folder below, you will find those pictures
NSLog(@"%@",deskTopDir);
NSLog(@"saving png");
NSString *pngFilePath = [NSString stringWithFormat:@"%@/jpg.png",deskTopDir];
NSData *data1 = [NSData dataWithData:UIImagePNGRepresentation(image)];
[data1 writeToFilengFilePath atomically:YES];
NSLog(@"saving jpeg");
NSString *jpegFilePath = [NSString stringWithFormat:@"%@/jpg.jpeg",deskTopDir];
NSData *data2 = [NSData dataWithData:UIImageJPEGRepresentation(image, 1.0f)];
[data2 writeToFile:jpegFilePath atomically:YES];
NSLog(@"saving image done");
[image release];
app2011 is offline   Reply With Quote
 

» Advertisements
» Online Users: 410
10 members and 400 guests
7twenty7, alexeir, Arty Tales, DaveDee, eski, Lily.P, networ, roof44, ryantcb, Sami Gh
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,594
Threads: 94,084
Posts: 402,779
Top Poster: BrianSlick (7,990)
Welcome to our newest member, kopmlop
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:14 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.