04-29-2008, 12:42 AM
I need to send an image captured by the camera to an HTTP server.
1. Does anyone know how to simulate the camera on the simulator ?
Assuming this is not possible (I don't have me developer certificate yet) I have resorted to picking up an image from the default photo library that comes with the simulator.
2. Does anyone know how to add my own photos to this simulator gallery ?
Following is my code where I pick up the image from the photo library. The (void)useImage
UIImage*)theImage function is called when the image is selected. This is what I want to send via an HTTP POST request to an HTTP server.
3. How do I convert the UIImage to a binary data format that the NSMutableURLRequest setHTTPBody function can use ?
1. Does anyone know how to simulate the camera on the simulator ?
Assuming this is not possible (I don't have me developer certificate yet) I have resorted to picking up an image from the default photo library that comes with the simulator.
2. Does anyone know how to add my own photos to this simulator gallery ?
Following is my code where I pick up the image from the photo library. The (void)useImage
UIImage*)theImage function is called when the image is selected. This is what I want to send via an HTTP POST request to an HTTP server. 3. How do I convert the UIImage to a binary data format that the NSMutableURLRequest setHTTPBody function can use ?
Code:
-(BOOL)snapAction:(id)sender
{
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
picker.allowsImageEditing = YES;
// Picker is displayed asynchronously.
[[self navigationController] presentModalViewController:picker animated:YES];
return YES;
}
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
[self useImage:image];
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissModalViewControllerAnimated:YES];
}
// Implement this method in your code to do something with the image.
- (void)useImage:(UIImage*)theImage
{
}
Thanks,
Sajid