views:

13

answers:

0

Ok so what I am trying to do is get an image from the camera roll, displaying it through the image view, and then getting some pixel data and modifying it (change brightness levels through the RGB values of the pixels). I'm a beginning dev and I can't seem to really get the hang of CGImage to actually get the pixel data. Could anyone help me? I have no idea if I am even going on the right direction. Here is some code that i have in my .m:

the converting the image to CGImage and getting the pixel data action is in the imagePickerController. Is that the right/good place to put it? THanks in advance to whoever helps me! I know this is a great place to get info!

Some code:

#import "SecondViewController.h"

@implementation SecondViewController

@synthesize theimageView, choosePhoto;
-(IBAction)switchBack{
    /*MainViewController *screen = [[MainViewController alloc] initWithNibName:nil bundle:nil];
    screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:screen animated:YES];
    [screen release];
    */

    [self dismissModalViewControllerAnimated:YES];



}



-(IBAction) getPhoto:(id) sender {
    UIImagePickerController * picker = [[UIImagePickerController alloc] init];  //initializes the picker
    picker.delegate = self;

    //if((UIButton *) sender == choosePhoto) {  //if statement for choosing between photo album and camera. camera not used in this case
    picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;  //calls the photo album
    //}

    [self presentModalViewController: picker animated:YES];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    [picker dismissModalViewControllerAnimated:YES];
    theimageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    myImage = [theimageView.image retain];  //saving the image
        CGImageRef mycgImage = [myImage CGImage];  //converting from UImage into a CGimage 

    CGDataProviderRef dataProvider = CGImageGetDataProvider(mycgImage);
    CFDataRef imageData = CGDataProviderCopyData(dataProvider);
    void *pixels = CFDataGetBytePtr(imageData);
}






@end

Can anyone help? Anyone want me to explain anything? Post more code? Thanks in advance!