Skip to content

Commit

Permalink
Add a bit of brightness decrease (but increase in practice) to make i…
Browse files Browse the repository at this point in the history
…nvert colors it look a bit more usable
  • Loading branch information
glouel committed Dec 2, 2024
1 parent b8296b5 commit 8fad6d1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
8 changes: 4 additions & 4 deletions Aerial.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3249,15 +3249,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3.5.2beta2;
CURRENT_PROJECT_VERSION = 3.5.2beta3;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 3L54M5L5KK;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/Resources/Old stuff/Info.plist";
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 3.5.2beta2;
MARKETING_VERSION = 3.5.2beta3;
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -3278,15 +3278,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3.5.2beta2;
CURRENT_PROJECT_VERSION = 3.5.2beta3;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 3L54M5L5KK;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/Resources/Old stuff/Info.plist";
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 3.5.2beta2;
MARKETING_VERSION = 3.5.2beta3;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
27 changes: 18 additions & 9 deletions Aerial/Source/Models/Extensions/AVPlayerItem+vibrance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,27 @@ extension AVPlayerItem {

func setColorInvert() {
if #available(OSX 10.14, *) {
debugLog("Applying color invert")
debugLog("Applying color invert with brightness adjustment")

if let filter = CIFilter(name: "CIColorInvert") {
self.videoComposition = AVVideoComposition(asset: asset, applyingCIFiltersWithHandler: { request in
let source = request.sourceImage.clampedToExtent()
filter.setValue(source, forKey: kCIInputImageKey)
let output = filter.outputImage
if let invertFilter = CIFilter(name: "CIColorInvert"),
let brightnessFilter = CIFilter(name: "CIColorControls") {

request.finish(with: output!, context: nil)
})
self.videoComposition = AVVideoComposition(asset: asset, applyingCIFiltersWithHandler: { request in
let source = request.sourceImage.clampedToExtent()

// First apply invert
invertFilter.setValue(source, forKey: kCIInputImageKey)

// Then apply brightness
brightnessFilter.setValue(invertFilter.outputImage, forKey: kCIInputImageKey)
brightnessFilter.setValue(-0.25, forKey: kCIInputBrightnessKey) // 25% decrease

let output = brightnessFilter.outputImage

request.finish(with: output!, context: nil)
})
}
}
}
}

}

0 comments on commit 8fad6d1

Please sign in to comment.