Joe Ginley
Joe Ginley

Reputation: 341

Flash effect using front facing camera Xcode

So I have searched for hours on a solution to this and have attempted using filters with no success. I was wondering how can I create a flash effect using the front face camera but then modify the image so it looks like it added the flash as if it was using the back camera? I know a few apps such as snapchat have done this but I could not find a tutorial on how to achieve it. I have tried adjusting brightness, gamma & exposure with no success.

NOTE: I know there is no flash on a front camera for iOS.

EDIT: I am thinking it is possible by setting the screen brightness to the max, animating then going back to the previous brightness.

Upvotes: 3

Views: 1651

Answers (2)

Joe Ginley
Joe Ginley

Reputation: 341

I was able to make this work by increasing the system brightness right before the photo was taken, then resetting the value back. This would allow such brightness to reflect against someones face when in a dark room. If anyone wants to see the code, let me know. It is in Swift.

Upvotes: 1

TRE
TRE

Reputation: 13

On an iOS device you take a screenshot when you press home + lock and the screen flashes white. Do you mean this effect? If so, try this:

Add a UIView with a white background color to your view hierarchy such that it covers the whole screen. Then, start an animation that fades the opacity of this view to zero. On completion, remove the view from its superview:

[UIView animateWithDuration: 0.5 
             animations: ^{
                           whiteView.alpha = 0.0;
                         }
             completion: ^(BOOL finished) {
                           [whiteView removeFromSuperview];
                         }
];

If you want the entire screen to flash, add the white view to the application's UIWindow and set the frame accordingly. All buttons work all the time, if you add the white view just in the moment before the animation starts and remove it on completion - except during the short flash

Upvotes: 1

Related Questions