From 18392104cd98a38aca41bc12219b459b6bcc0076 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 21 Nov 2022 11:34:39 -0500 Subject: [PATCH] Fix byte order preventing some masks from being created --- SilicaViewer/Document.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/SilicaViewer/Document.swift b/SilicaViewer/Document.swift index 561eac7..74b2b08 100644 --- a/SilicaViewer/Document.swift +++ b/SilicaViewer/Document.swift @@ -201,7 +201,14 @@ class Document: NSDocument { let render: CGColorRenderingIntent = .defaultIntent let rgbColorSpace = isMask ? CGColorSpaceCreateDeviceGray() : info.colorSpace - let bitmapInfo = CGBitmapInfo(rawValue: (isMask ? CGImageAlphaInfo.none : CGImageAlphaInfo.premultipliedLast).rawValue).union(.byteOrder32Big) + var bitmapInfo = CGBitmapInfo(rawValue: (isMask ? CGImageAlphaInfo.none : CGImageAlphaInfo.premultipliedLast).rawValue) + + if isMask { + bitmapInfo = bitmapInfo.union(.byteOrderDefault) + } else { + bitmapInfo = bitmapInfo.union(.byteOrder32Big) + } + let providerRef: CGDataProvider? = CGDataProvider(data: imageData as CFData) guard let cgimage = CGImage(width: tileWidth,