es ein wenig knifflig kann, die sich mit der auf die Vorschau des Bildes angewendet Transformation, die es ein wenig anders als die aussehen lässt Sie von der Kamera übergeben bekommen, aber hier ist die Grundidee:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *img = [info objectForKey:UIImagePickerControllerOriginalImage];
// Here we are throwing away lots of image resolution -- but since our art is built for the 320 x 480 screen
// and we are worried about uploading bandwidth, crunching the image down from ~1600 x 2400 to 320 x 480 just makes sense
// note that the proportion is a little different, so the picture is slightly stretched in the y-axis, but this is augmented reality, so we like that
// note that hardwareScreenSize has to be determined by checking UIDeviceHardware
UIGraphicsBeginImageContext(hardwareScreenSize);
[img drawInRect:CGRectMake(0, ((hardwareScreenSize.height - hardwareScreenSize.height)/2), hardwareScreenSize.width, hardwareScreenSize.height)];
// this scales overlayImage to fit ontop of camera image
[(UIImage *)overlayImage drawInRect:CGRectMake(0, 0, hardwareScreenSize.width, hardwareScreenSize.height)];
UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
[finalImage retain];
UIGraphicsEndImageContext();
wenn ich [(UIImage *) overlayImage drawInRect: CGRectMake (0, 0, hardwareScreenSize.width, hardwareScreenSize.height)]; es gibt Overlay-Bild. Aber wenn ich die x- und y-Position des Überlagerungsbilds ändere, dann nehme ich einen Schnappschuss, es wird keine neue x- und y-Größe ergeben. – Ram