objective c - how to integrate camera application in app -


i new ios. integrated camera application in app. want crop taken image.

i got error while running. solve this
cgimagecreatewithimageprovider: invalid image size: 0 x 0.

this code:  - (ibaction)camera:(id)sender {     if ([uiimagepickercontroller issourcetypeavailable:          uiimagepickercontrollersourcetypecamera])     {         uiimagepickercontroller *imagepicker =         [[uiimagepickercontroller alloc] init];         imagepicker.delegate = self;         imagepicker.sourcetype =         uiimagepickercontrollersourcetypecamera;         imagepicker.mediatypes = [nsarray arraywithobjects:                                   (nsstring *) kuttypeimage,                                   nil];         imagepicker.allowsediting = no;         [self presentmodalviewcontroller:imagepicker                                 animated:yes];          newmedia = yes;     } }  - (ibaction)gallery:(id)sender {      if ([uiimagepickercontroller issourcetypeavailable:          uiimagepickercontrollersourcetypesavedphotosalbum])     {         uiimagepickercontroller *imagepicker =         [[uiimagepickercontroller alloc] init];         imagepicker.delegate = self;         imagepicker.sourcetype =         uiimagepickercontrollersourcetypephotolibrary;         imagepicker.mediatypes = [nsarray arraywithobjects:                                   (nsstring *) kuttypeimage,                                   nil];         imagepicker.allowsediting = no;         [self presentmodalviewcontroller:imagepicker animated:yes];          newmedia = no;     } }  - (ibaction)crop:(id)sender {       float xco,yco;               float width=bottomcornerpoint.x-topcornerpoint.x;      float height=bottomcornerpoint.y-topcornerpoint.y;       if(width<0)          width=-width;       if(height<0)          height=-height;       if(topcornerpoint.x <bottomcornerpoint.x)      {          xco=topcornerpoint.x;      }      else     {         xco=bottomcornerpoint.x;     }       if(topcornerpoint.y <bottomcornerpoint.y)      {          yco=topcornerpoint.y;      }       else {          yco=bottomcornerpoint.y;      }       cgrect rect = cgrectmake(xco,yco,width,height);       uiimage *image = [uiimage imagenamed:@"mehandi.jpg"];       cgimageref imageref = cgimagecreatewithimageinrect([image cgimage], rect);      uiimage *img = [uiimage imagewithcgimage:imageref];      cgimagerelease(imageref);       imageview = [[uiimageview alloc] initwithimage:img];      [imageview setframe:cgrectmake(110, 600, width, height)];      imageview.image=img;      [[self view] addsubview:imageview];          }    -(void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info {     nsstring *mediatype = [info                            objectforkey:uiimagepickercontrollermediatype];     [self dismissmodalviewcontrolleranimated:yes];     if ([mediatype isequaltostring:(nsstring *)kuttypeimage]) {         uiimage *image = [info                           objectforkey:uiimagepickercontrolleroriginalimage];          imageview.image = image;         if (newmedia)             uiimagewritetosavedphotosalbum(image,                                            self,                                            @selector(image:finishedsavingwitherror:contextinfo:),                                            nil);     }  } -(void)image:(uiimage *)image finishedsavingwitherror:(nserror *)error  contextinfo:(void *)contextinfo {     if (error) {         uialertview *alert = [[uialertview alloc]                               initwithtitle: @"save failed"                               message: @"failed save image"\                               delegate: nil                               cancelbuttontitle:@"ok"                               otherbuttontitles:nil];         [alert show];   } -(void)imagepickercontrollerdidcancel:(uiimagepickercontroller *)picker {     [self dismissmodalviewcontrolleranimated:yes]; } 


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -