GPUImage icon indicating copy to clipboard operation
GPUImage copied to clipboard

forceProcessingAtSize separated preview

Open valvoline opened this issue 14 years ago • 1 comments

Is there a way to preview a separated frame size from the one that will be saved?

I've tried the following, with no luck:

- (void)viewDidLoad
{
    [super viewDidLoad];

    stillCamera = [[GPUImageStillCamera alloc] init];

    filter = [[GPUImageCustomFilter alloc] init];
    [filter forceProcessingAtSize:CGSizeMake(640, 960)];

    GPUImageRotationFilter *rotationFilter = [[GPUImageRotationFilter alloc] initWithRotation:kGPUImageRotateRight];

    [filter prepareForImageCapture];

    [stillCamera addTarget:rotationFilter];

    GPUImageView *filterView = (GPUImageView *)self.view;

    [rotationFilter addTarget:filter];
    [filter addTarget:filterView];

    [stillCamera startCameraCapture];
}

and on the takePhoto method:

- (IBAction)takePhoto:(id)sender;
{
    [filter forceProcessingAtSize:CGSizeMake(1500, 2000)];

    [stillCamera capturePhotoProcessedUpToFilter:filter withCompletionHandler:^(UIImage *anImage, NSError *error){
        [[NSNotificationCenter defaultCenter] postNotificationName:@"photoWasShooted" object:nil userInfo:[NSDictionary dictionaryWithObject:anImage forKey:@"shoot"]];
        [self dismissModalViewControllerAnimated:TRUE];
    }];
}

valvoline avatar May 02 '12 07:05 valvoline

Ok,

Solved the issue, using a separated filter for the takePhoto method as follow:

- (IBAction)takePhoto:(id)sender;
{
    [stillCamera removeAllTargets];
    GPUImageCustomFilter *fullSizeFilter = [[GPUImageCustomFilter alloc] init];
    [fullSizeFilter forceProcessingAtSize:CGSizeMake(1500, 2000)];

    [stillCamera capturePhotoProcessedUpToFilter:fullSizeFilter withCompletionHandler:^(UIImage *anImage, NSError *error){
        [[NSNotificationCenter defaultCenter] postNotificationName:@"photoWasShooted" object:nil userInfo:[NSDictionary dictionaryWithObject:anImage forKey:@"shoot"]];
        [self dismissModalViewControllerAnimated:TRUE];
    }];
}

valvoline avatar May 02 '12 08:05 valvoline