Objective c 从UIImageView获取UIImage
目前我正在开发一款基于摄像头的应用程序。我在UIImageView中添加了摄像头图像,以便于操作。现在我想增加一些核心成像的效果。我能从视图中得到一个图像吗 这就是我添加效果的方式,但它仅适用于图像Objective c 从UIImageView获取UIImage,objective-c,uiimageview,uiimage,Objective C,Uiimageview,Uiimage,目前我正在开发一款基于摄像头的应用程序。我在UIImageView中添加了摄像头图像,以便于操作。现在我想增加一些核心成像的效果。我能从视图中得到一个图像吗 这就是我添加效果的方式,但它仅适用于图像 NSString *filePath = [[NSBundle mainBundle] pathForResource:@"IpadIcon" ofType:@"png"]; NSURL *fileNameAndPath = [NSURL fileURLWithPath:filePath]; CI
NSString *filePath =
[[NSBundle mainBundle] pathForResource:@"IpadIcon" ofType:@"png"];
NSURL *fileNameAndPath = [NSURL fileURLWithPath:filePath];
CIImage *beginImage =
[CIImage imageWithContentsOfURL:fileNameAndPath];
CIContext *context = [CIContext contextWithOptions:nil];
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone" keysAndValues: kCIInputImageKey, beginImage, @"inputIntensity", [NSNumber numberWithFloat:0.8], nil];
CIImage *outputImage = [filter outputImage];
CGImageRef cgimg =
[context createCGImage:outputImage fromRect:[outputImage extent]];
UIImage *newImg = [UIImage imageWithCGImage:cgimg];
[captureImage setImage:newImg];
获取图像
- (void) capImage { //method to capture image from AVCaptureSession video feed
AVCaptureConnection *videoConnection = nil;
for (AVCaptureConnection *connection in stillImageOutput.connections) {
for (AVCaptureInputPort *port in [connection inputPorts]) {
if ([[port mediaType] isEqual:AVMediaTypeVideo] ) {
videoConnection = connection;
break;
}
}
if (videoConnection) {
break;
}
}
[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
if (imageSampleBuffer != NULL) {
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
[self processImage:[UIImage imageWithData:imageData]];
}
}];
}
使用UIImageView的
image
属性获取图像:
UIImage*theImage=imageView.image代码>您能更具体地说明您遇到的问题吗?UIImageView中有一张图片。现在我需要把它拿出来。可能吗?UIImage*theImage=imageView.image代码>?我现在觉得自己很愚蠢。你能把它写在纸上吗?这样我就可以给你评分了