jgh- / VideoCore-Inactive

*No longer in development* Please see https://github.com/unpause-live/SwiftVideo
MIT License
1.48k stars 540 forks source link

Pinch to zoom in zoom out #164

Open markmark1 opened 9 years ago

markmark1 commented 9 years ago

How do you implement pinch zoom and zoom out in our videocore apps, i am using a uiview and slide to zoom

This would be a great to use ui feature for recording

JALsnipe commented 9 years ago

Zoom is explained in Issue #155. If you have a programming question, say how to implement a pinch gesture, your question is better suited for StackOverflow.

walkermi commented 9 years ago

UIPinchGestureRecognizer *pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)]; [self.mView addGestureRecognizer:pinchGestureRecognizer];

I tried using the videoZoomFactor but I don't see any difference.

maxcampolo commented 9 years ago

This is how I did it

- (void)handlePinchReceived:(UIPinchGestureRecognizer*)sender {
    if (sender.scale > 1) {
        // Zoom in
        if (_session.videoZoomFactor  * sender.scale > 5) {
            _session.videoZoomFactor = 5;
        } else {
            _session.videoZoomFactor = _session.videoZoomFactor * sender.scale;
        }
        NSLog(@"Zoom: %f", _session.videoZoomFactor);
    } else {
        // Zoom out
        if (_session.videoZoomFactor * sender.scale < 1) {
            _session.videoZoomFactor = 1.0;
        } else {
            _session.videoZoomFactor = _session.videoZoomFactor * sender.scale;
        }
        NSLog(@"Zoom: %f", _session.videoZoomFactor);
    }
    //NSLog(@"%f", sender.scale);
    sender.scale = 1.0;
}