Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ljg93

macrumors member
Original poster
Mar 13, 2011
98
0
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?
 
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.

Code:
- (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];
}

Code:
    NSData *imageData;
    NSData *imageDataTotal;

Don't forget to do to the copy, and work with that. Because of a BAD_EXCES.
=)
 
Hey thanks for your post, but where would i define the imagefromcamera at?
 
Code:
INTERFACE
   UIImagePickerController* imagePickerController;
    UIImage *imageFromCamera;
    NSData *imageData;
    NSData *imageDataTotal;
}

@property (nonatomic, retain) UIImage *imageFromCamera;

- (void) startTheCamera;
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.