我的UIImage是零,如果我嘗試測試的代碼塊:的UIImage返回nil(xcode5)
- (IBAction)sliderBrightness:(id)sender {
UIImage *inputImage = imgView.image;
GPUImageBrightnessFilter *stillImageFilter = [[GPUImageBrightnessFilter alloc] init];
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:inputImage];
[stillImageSource addTarget:stillImageFilter];
[stillImageFilter useNextFrameForImageCapture];
[stillImageSource processImage];
UIImage *currentFilteredVideoFrame = [stillImageFilter imageFromCurrentFramebuffer];
[self->imgView setImage:currentFilteredVideoFrame];
}
UPDATE:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
imgView.image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
toolbar.hidden = NO;
UIImage *image1 = imgView.image;
NSString *cachedFolderPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];
NSString *cachedImagePath = [cachedFolderPath stringByAppendingPathComponent:@"image1.png"];
[UIImagePNGRepresentation(image1) writeToFile:cachedImagePath atomically:YES];
}
if (picker.sourceType == UIImagePickerControllerSourceTypePhotoLibrary) {
toolbar.hidden = NO;
UIImage *image1 = imgView.image;
NSString *cachedFolderPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];
NSString *cachedImagePath = [cachedFolderPath stringByAppendingPathComponent:@"image1.png"];
[UIImagePNGRepresentation(image1) writeToFile:cachedImagePath atomically:YES];
}
if (picker.sourceType == UIImagePickerControllerSourceTypeSavedPhotosAlbum) {
toolbar.hidden = NO;
UIImage *image1 = imgView.image;
NSString *cachedFolderPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];
NSString *cachedImagePath = [cachedFolderPath stringByAppendingPathComponent:@"image1.png"];
[UIImagePNGRepresentation(image1) writeToFile:cachedImagePath atomically:YES];
}
else{
toolbar.hidden = NO;
}
[self dismissViewControllerAnimated:YES completion:nil];
}
調試器(inputImage的是無):
我希望有人能幫助我。 在此先感謝您的幫助。
我使用的Xcode 5.1.1(iPhone模擬器:iPhone 4英寸; 64位; iOS7.1)
你是怎麼設置'imgView.image'的? – Logan
我在這個IBAction後的方法中設置了imgView.image(imgView.image = [info objectForKey:@「UIImagePickerControllerEditedImage」];) – user3576580
*哪個*圖像爲零? 'inputImage'或'currentFilteredVideoFrame'? – Caleb