PDA

View Full Version : message composer sample code/photo picker sample code




ljg93
May 31, 2011, 11:21 PM
Hey

I was using the photo picker sample code along with the message composer sample code

I threw in a button on the photo picker sample code toolbar to go to a email, how would i go about attaching the image that is on screen of the photo picker into the email?



jnoxx
Jun 1, 2011, 02:13 AM
Hey

I was using the photo picker sample code along with the message composer sample code

I threw in a button on the photo picker sample code toolbar to go to a email, how would i go about attaching the image that is on screen of the photo picker into the email?

Well, you could save the image representation u get from the camera, into a local variable. and add that into the email or something.

Here is some code including to scale it, so it doesn't clog up memory when u are trying to use it as background or similair.

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Access the uncropped image from info dictionary
UIImage* image = (UIImage* ) [info objectForKey:@"UIImagePickerControllerOriginalImage"];
imageFromCamera = [image copy];

// Save image
UIImageWriteToSavedPhotosAlbum(imageFromCamera, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
[picker release];

CGSize size = CGSizeMake(768, 1024);
UIGraphicsBeginImageContext(size);// a CGSize that has the size you want
[imageFromCamera drawInRect:CGRectMake(0,0,size.width,size.height)];
//image is the original UIImage
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

imageData = UIImageJPEGRepresentation(newImage, 0.5);
imageDataTotal = [imageData copy];
}

NSData *imageData;
NSData *imageDataTotal;

Don't forget to do to the copy, and work with that. Because of a BAD_EXCES.
=)

ljg93
Jun 2, 2011, 12:29 AM
Hey thanks for your post, but where would i define the imagefromcamera at?

jnoxx
Jun 3, 2011, 02:47 AM
INTERFACE
UIImagePickerController* imagePickerController;
UIImage *imageFromCamera;
NSData *imageData;
NSData *imageDataTotal;
}

@property (nonatomic, retain) UIImage *imageFromCamera;

- (void) startTheCamera;