From a801579bc16b1cc5d8362bd89f69ff87d9fd9a83 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 29 Sep 2021 16:30:57 -0400 Subject: [PATCH] Fix alpha --- SilicaViewer/Document.swift | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/SilicaViewer/Document.swift b/SilicaViewer/Document.swift index f6c405c..2c47245 100644 --- a/SilicaViewer/Document.swift +++ b/SilicaViewer/Document.swift @@ -240,7 +240,7 @@ class Document: NSDocument { return .luminosity } - return .sourceAtop + return .sourceOver } func parseSilicaLayer(archive: Archive, dict: NSDictionary, isMask: Bool) -> SilicaLayer? { @@ -320,7 +320,7 @@ class Document: NSDocument { let render: CGColorRenderingIntent = .defaultIntent let rgbColorSpace = isMask ? CGColorSpaceCreateDeviceGray() : info.colorSpace - let bitmapInfo = CGBitmapInfo(rawValue: (isMask ? CGImageAlphaInfo.none : CGImageAlphaInfo.last).rawValue).union(.byteOrder32Big) + let bitmapInfo = CGBitmapInfo(rawValue: (isMask ? CGImageAlphaInfo.none : CGImageAlphaInfo.premultipliedLast).rawValue).union(.byteOrder32Big) let providerRef: CGDataProvider? = CGDataProvider(data: imageData as CFData) guard let cgimage = CGImage(width: width, height: height, bitsPerComponent: 8, bitsPerPixel: 8 * numChannels, bytesPerRow: width * numChannels, space: rgbColorSpace, bitmapInfo: bitmapInfo, provider: providerRef!, decode: nil, shouldInterpolate: false, intent: render) else { @@ -504,9 +504,7 @@ class Document: NSDocument { var maskContext: CGContext? let kernel = getBlendKernel(layer) - - Swift.print(layer.name + " is " + kernel!.name) - + if layer.mask != nil { let grayColorSpace = CGColorSpaceCreateDeviceGray() let maskBitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.none.rawValue).union(.byteOrder16Big)