This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SwiftUI | |
import UIKit | |
extension UIBlurEffect { | |
public static func variableBlurEffect(radius: Double, imageMask: UIImage) -> UIBlurEffect? { | |
let methodType = (@convention(c) (AnyClass, Selector, Double, UIImage) -> UIBlurEffect).self | |
let selectorName = ["imageMask:", "effectWithVariableBlurRadius:"].reversed().joined() | |
let selector = NSSelectorFromString(selectorName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###### CONSISTENCY BETWEEN MACOS AND IOS ##### | |
# | |
# In order to use the same PodFile with MacOS, we need to unlink the libraries that do not support Catalyst, filter | |
# files in native targets build phases, filter dependencies and make sure the unsupported frameworks along with their | |
# their bundle resources are not included in the final archive. For that, we use `platform_filter` to specify 'ios' and | |
# 'OTHER_LDFLAGS[sdk=iphone*]' to link those libraries for iPhone and iPad. Besides, we modify "*frameworks.sh" and | |
# "*resrouces.sh" to skip installation for architecture x86_64. | |
# | |
# *Notice*: 'sdk=iphone*' excludes macOS, even though Catalyst is compiled with iOS SDK. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Author: Gilbert Francois Duivesteijn | |
# Date: Febr 2023 | |
# Platform: macOS | |
# License: Apache | |
# Discard receipt data for the installed GStreamer packages. | |
pkgutil --pkgs | grep gstreamer | xargs -I % sudo pkgutil --forget % | |
# Remove the GStreamer Framework from disk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// Interactive Animated Presentation | |
// "Visor" Effect | |
// | |
import UIKit | |
class ViewController: UIViewController { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// RepeatingTimer mimics the API of DispatchSourceTimer but in a way that prevents | |
/// crashes that occur from calling resume multiple times on a timer that is | |
/// already resumed (noted by https://github.com/SiftScience/sift-ios/issues/52 | |
class RepeatingTimer { | |
let timeInterval: TimeInterval | |
init(timeInterval: TimeInterval) { | |
self.timeInterval = timeInterval | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <CoreMedia/CoreMedia.h> | |
#import <CoreVideo/CoreVideo.h> | |
#import <UIKit/UIKit.h> | |
// https://developer.apple.com/library/content/qa/qa1702/_index.html | |
+ (UIImage * _Nullable)imageWithSampleBuffer:(CMSampleBufferRef _Nonnull)sampleBuffer { | |
UIImage *returnValue = nil; | |
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); | |
CVPixelBufferLockBaseAddress(imageBuffer, 0); { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension CVPixelBuffer | |
{ | |
/// Deep copy a CVPixelBuffer: | |
/// http://stackoverflow.com/questions/38335365/pulling-data-from-a-cmsamplebuffer-in-order-to-create-a-deep-copy | |
func copy() -> CVPixelBuffer | |
{ | |
precondition(CFGetTypeID(self) == CVPixelBufferGetTypeID(), "copy() cannot be called on a non-CVPixelBuffer") | |
var _copy: CVPixelBuffer? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension CVPixelBuffer { | |
func deepcopy() -> CVPixelBuffer? { | |
let width = CVPixelBufferGetWidth(self) | |
let height = CVPixelBufferGetHeight(self) | |
let format = CVPixelBufferGetPixelFormatType(self) | |
var pixelBufferCopyOptional:CVPixelBuffer? | |
CVPixelBufferCreate(nil, width, height, format, nil, &pixelBufferCopyOptional) | |
if let pixelBufferCopy = pixelBufferCopyOptional { | |
CVPixelBufferLockBaseAddress(self, kCVPixelBufferLock_ReadOnly) | |
CVPixelBufferLockBaseAddress(pixelBufferCopy, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); | |
CVPixelBufferLockBaseAddress(imageBuffer,0); | |
size_t height = CVPixelBufferGetHeight(imageBuffer); | |
size_t width = CVPixelBufferGetWidth(imageBuffer); | |
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer); | |
void *sourceData = CVPixelBufferGetBaseAddress(imageBuffer); | |
// Set a bunch of variables we need. The "radius" for the blur kernel needs to be positive and odd. The permute map maps the BGRA channels of the buffer to the ARGB that vImage needs. |
NewerOlder