Skip to content

Instantly share code, notes, and snippets.

View willbur1984's full-sized avatar

William Towe willbur1984

View GitHub Profile
- (CMSampleBufferRef)videoCapture:(RTCVideoCaptureIosObjC *)videoCapture modifiedSampleBufferFromSampleBuffer:(CMSampleBufferRef)sampleBuffer frameWasModified:(BOOL *)frameWasModified {
[self setUsingWebRTCCapture:YES];
CVImageBufferRef imageBufferRef = CMSampleBufferGetImageBuffer(sampleBuffer);
CIImage *image = [[CIImage imageWithCVImageBuffer:imageBufferRef] imageByApplyingTransform:CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI_2), 1, 1)];
CMSampleBufferRef retval = sampleBuffer;
if (self.selectedFilter != nil) {
image = [self.selectedFilter filteredImageFromImage:image context:self.coreImageContext];
@willbur1984
willbur1984 / UIImage+Saturation.m
Created September 16, 2015 15:54
UIImage+Saturation using accelerate
+ (UIImage *)BB_imageByAdjustingSaturationOfImage:(UIImage *)image delta:(CGFloat)delta; {
NSParameterAssert(image);
// if user passed really small delta, it wont make any difference, just return the original image
if (fabs(delta - 1.0) < __FLT_EPSILON__) {
return image;
}
// https://dvcs.w3.org/hg/FXTF/raw-file/default/filters/index.html#grayscaleEquivalent
CGFloat floatingPointSaturationMatrix[] = {
@willbur1984
willbur1984 / UIImage+Saturation.m
Created September 15, 2015 18:47
UIImage saturation adjustment using CoreImage
+ (UIImage *)BB_imageByAdjustingSaturationOfImage:(UIImage *)image delta:(CGFloat)delta; {
NSParameterAssert(image);
CIFilter *filter = [CIFilter filterWithName:@"CIColorControls"];
[filter setDefaults];
[filter setValue:@(delta) forKey:@"inputSaturation"];
[filter setValue:[CIImage imageWithCGImage:image.CGImage] forKey:@"inputImage"];
CIImage *output = [filter valueForKey:@"outputImage"];
@willbur1984
willbur1984 / plist.sh
Created September 14, 2015 20:03
adjust ios plist version numbers
#
# Set the build number to the current git commit count.
# If we're using the Dev scheme, then we'll suffix the build
# number with the current branch name, to make collisions
# far less likely across feature branches.
# Based on: http://w3facility.info/question/how-do-i-force-xcode-to-rebuild-the-info-plist-file-in-my-project-every-time-i-build-the-project/
#
git=`sh /etc/profile; which git`
appBuild=`"$git" rev-list --all |wc -l`
if [ $CONFIGURATION = "Debug" ]; then
@willbur1984
willbur1984 / UIImage+Render.m
Created September 14, 2015 19:03
UIImage render snippet
+ (UIImage *)BB_imageByRenderingImage:(UIImage *)image withColor:(UIColor *)color; {
NSParameterAssert(image);
NSParameterAssert(color);
UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale);
[color setFill];
[[image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] drawAtPoint:CGPointZero blendMode:kCGBlendModeNormal alpha:1.0];
UIImage *retval = [UIGraphicsGetImageFromCurrentImageContext() imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
@willbur1984
willbur1984 / gist:5415436
Created April 18, 2013 19:10
standard MIT license
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS