I’ve been using
// Fill in a mask buffer, with black pixels for what's explored
UInt8* bufr = malloc(aSize.width * aSize.height * kBytesPerMaskPixel);
memset(bufr, 0xFF, aSize.width * aSize.height * kBytesPerMaskPixel); // Clear (to white)
// Now we loop through the hexes and draw the appropriate ones.
// Create a 1-bit mask image (still with 8 bits per pixel)
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, bufr, aSize.width * aSize.height, NULL);
CGImageRef maskImage = CGImageMaskCreate(aSize.width, aSize.height, kBytesPerMaskPixel, 8, aSize.width, provider, nil, false);and in iOS 12, get the assertion
Assertion failed: (bitsPerComponent == 8), function CGImageMaskCreate, file /BuildRoot/Library/Caches/com.apple.xbs/Sources/CoreGraphics/CoreGraphics-1216.4.3/CoreGraphics/Images/CGImage.c, line 636.
The documentation still says “Image masks must be 1, 2, 4, or 8 bits per component” so I wonder if this is a known change, a bug [I filed 40901713], or something that shouldn’t have worked in the past. (I would hate to take 8 times the memory for this mask.)
Oh,
#define kBytesPerMaskPixel 1