Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Palace.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4732,6 +4732,8 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 390;
CURRENT_PROJECT_VERSION = 391;
DEVELOPMENT_TEAM = 88CBA74T8K;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K;
ENABLE_BITCODE = NO;
Expand All @@ -4753,7 +4755,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.0;
MARKETING_VERSION = 2.0.1;
PRODUCT_BUNDLE_IDENTIFIER = org.thepalaceproject.palace;
PRODUCT_MODULE_NAME = Palace;
PRODUCT_NAME = "Palace-noDRM";
Expand Down Expand Up @@ -4791,6 +4793,8 @@
CODE_SIGN_ENTITLEMENTS = Palace/SimplyE.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 390;
CURRENT_PROJECT_VERSION = 391;
DEVELOPMENT_TEAM = 88CBA74T8K;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K;
ENABLE_BITCODE = NO;
Expand All @@ -4812,7 +4816,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.0;
MARKETING_VERSION = 2.0.1;
PRODUCT_BUNDLE_IDENTIFIER = org.thepalaceproject.palace;
PRODUCT_MODULE_NAME = Palace;
PRODUCT_NAME = "Palace-noDRM";
Expand Down Expand Up @@ -4975,6 +4979,8 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 390;
CURRENT_PROJECT_VERSION = 391;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -5036,6 +5042,8 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 389;
CURRENT_PROJECT_VERSION = 390;
CURRENT_PROJECT_VERSION = 391;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K;
ENABLE_BITCODE = NO;
Expand Down
32 changes: 27 additions & 5 deletions Palace/Book/Models/TPPBook.swift
Original file line number Diff line number Diff line change
Expand Up @@ -600,22 +600,44 @@ private extension TPPBook {
DispatchQueue.global(qos: .userInitiated).async { [weak self] in
guard let self = self else { return }

let ciImage = CIImage(image: inputImage)
guard let ciImage = CIImage(image: inputImage) else {
Log.debug(#file, "Failed to create CIImage from UIImage for book: \(self.identifier)")
return
}

guard !ciImage.extent.isEmpty else {
Log.debug(#file, "CIImage has empty extent for book: \(self.identifier)")
return
}

let filter = CIFilter.areaAverage()
filter.inputImage = ciImage
filter.extent = ciImage?.extent ?? .zero
filter.extent = ciImage.extent

guard let outputImage = filter.outputImage else { return }
guard let outputImage = filter.outputImage else {
Log.debug(#file, "Failed to generate output image from filter for book: \(self.identifier)")
return
}

guard let colorSpace = CGColorSpace(name: CGColorSpace.sRGB) else {
Log.debug(#file, "Failed to create sRGB color space for book: \(self.identifier)")
return
}

var bitmap = [UInt8](repeating: 0, count: 4)
let context = CIContext(options: [CIContextOption.useSoftwareRenderer: false])
let context = CIContext(options: [
.workingColorSpace: colorSpace,
.outputColorSpace: colorSpace,
.useSoftwareRenderer: false
])

context.render(
outputImage,
toBitmap: &bitmap,
rowBytes: 4,
bounds: CGRect(x: 0, y: 0, width: 1, height: 1),
format: .RGBA8,
colorSpace: nil
colorSpace: colorSpace
)

let color = UIColor(
Expand Down
Loading