ios - UIImagePickerController overlaying an image on top of it correctly -


about question:

  • device: ipod touch 4th gen (640 * 960 retina display resolution)
  • os: ios 6
  • dev kit: xcode 5.0.2
  • source code try modify: photopicker example
  • aim: add image on top of uiimagepickercontroller view

description:

i modifying photopicker example apple aim add custom png image displayed above camera lenses before taking picture. image indicate user has put his/her face.

the image below shows , want. can see seems original image rescaled , becomes way big.

enter image description here

the main method called when "camera" button tapped following. modified adding uiimageview subview imagepickercontroller, initialized uiimageview uiimage containing original 640*960 image.

when run piece of code on ipod 4th generation (640 * 960) seems image scaled lot. how can fix code below allow image overlay camera? (the dot should appear in center , black borders in borders)

 - (void)showimagepickerforsourcetype:(uiimagepickercontrollersourcetype)sourcetype {     if (self.imageview.isanimating)     {         [self.imageview stopanimating];     }      if (self.capturedimages.count > 0)     {         [self.capturedimages removeallobjects];     }      uiimagepickercontroller *imagepickercontroller = [[uiimagepickercontroller alloc] init];     imagepickercontroller.modalpresentationstyle = uimodalpresentationcurrentcontext;     imagepickercontroller.sourcetype = sourcetype;     imagepickercontroller.delegate = self;      if (sourcetype == uiimagepickercontrollersourcetypecamera)     {         /*          user wants use camera interface. set our custom overlay view camera.          */         imagepickercontroller.showscameracontrols = no;           // set rear camera         imagepickercontroller.cameradevice = uiimagepickercontrollercameradevicefront;          /*          load overlay view overlayview nib file. self file's owner nib file, overlayview outlet set main view in nib. pass view image picker controller use overlay view, , set self's reference view nil.          */         [[nsbundle mainbundle] loadnibnamed:@"overlayview" owner:self options:nil];         self.overlayview.frame = imagepickercontroller.cameraoverlayview.frame;         imagepickercontroller.cameraoverlayview = self.overlayview;         self.overlayview = nil;          uiimage * imageoffaces = [uiimage imagewithcontentsoffile:[[nsbundle mainbundle] pathforresource:@"photo border" oftype:@"png"]];          uiimageview * imageviewoffaces = [[uiimageview alloc] initwithimage:imageoffaces];          [imagepickercontroller.view addsubview:imageviewoffaces];        [imageviewoffaces sizetofit];     }      self.imagepickercontroller = imagepickercontroller;     [self presentviewcontroller:self.imagepickercontroller animated:yes completion:nil]; } 

full size images:

here png image overlay (is 640w * 960h pixel):

enter image description here

however result:

enter image description here

make sure image has retina suffix this:

image@2x.png 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -