我的申请是关于从画廊照片或相机拍照。例如,如果我从图片库中拍照并显示它。如果我显示它。它给我看了一瓶。我应该移动那个瓶子,并且只对从作为imageview的瓶子里面的画廊挑选的图像进行干扰。像这样:http://postimg.org/image/aw6a7g3t3/
这是我的代码:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[ButtonPicture setBackgroundImage:[UIImage imageNamed:@"save1.png"] forState:UIControlStateNormal];
imageChanged = YES;
[picker dismissModalViewControllerAnimated:YES];
imageviewPicture.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
imageN= [info objectForKey:@"UIImagePickerControllerOriginalImage"];
im = [CIImage imageWithCGImage:imageN.CGImage];
UIImage *image = [UIImage imageNamed: @"bottle1.png"];
[bottle setImage:image];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
printf("touch began ----------- \n");
im = [CIImage imageWithCGImage:imageN.CGImage];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
printf("touch moved \n" );
UITouch *myTouch = [touches anyObject];
startPoint = [myTouch locationInView:self.view];
//////Distortion
imageviewPicture.image = imageN;
// imageviewPicture.image.
im = [CIImage imageWithCGImage:imageN.CGImage];
CIFilter *filter = [CIFilter filterWithName:@"CIBumpDistortion"];
// filter.accessibilityActivationPoint = CGPointMake(startPoint.x, startPoint.y);
[filter setValue:im forKey:kCIInputImageKey];
[filter setValue:[CIVector vectorWithX:startPoint.x Y:startPoint.y] forKey:@"inputCenter"];
// [filter setValue:[NSNumber numberWithFloat:150.0] forKey:@"inputAngle"];
// [filter setValue:[NSNumber numberWithFloat:300.00] forKey:@"inputRadius"];
// [filter setValue:[NSNumber numberWithFloat:0.50] forKey:@"inputScale"];
CIImage *result = [filter valueForKey:kCIOutputImageKey];
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef ref = [context createCGImage:result fromRect:result.extent];
UIImage * uiImage = [[UIImage alloc]initWithCGImage:ref];
[self->imageviewPicture setImage:uiImage];
CGImageRelease(ref);
///////////
//we move the bottle
bottle.center = CGPointMake(startPoint.x, startPoint.y);
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
printf("touch end ----------- \n");
}
现在的问题是当我触摸瓶子以将失真效果应用于图像时。它应用效果,但每当我移动瓶子时图像变小。提前致谢