I've ran into a problem when reading a high-efficiency image file and converting it into 24-bit (packed without alpha channel) vImage for further processing. The resulting image has vertical black bands in some parts and other vertical bands in which some channels are missing (i.e has a magenta or green tone to it). The problem appears ony when the source image is 3000x2000 pixels or greater.Here is a Playground code to reproduce the issue – unfortunately I can't find a way to attach files here.import Cocoa
import Accelerate
// width: 2000 pixels results in no banding
// but width 3000 pixels results in banded image
let imageFileURL = Bundle.main.url(forResource: "sample_3000", withExtension: "heic")!
let imageSource = CGImageSourceCreateWithURL(imageFileURL as CFURL, nil)!
let originalImage = CGImageSourceCreateImageAtIndex(imageSource, 0, nil)!
let colorSpace = CGColorSpace(name: CGColorSpace.sRGB)!
var expectedImageFormat = vImage_CGImageFormat(
bitsPerComponent: UInt32(8),
bitsPerPixel: UInt32(8 * 3),
colorSpace: Unmanaged.passUnretained(colorSpace),
bitmapInfo: CGBitmapInfo(rawValue: CGBitmapInfo.byteOrder32Big.rawValue | CGImageAlphaInfo.none.rawValue),
version: 0,
decode: nil,
renderingIntent: originalImage.renderingIntent
)
var buff = vImage_Buffer()
buff.height = vImagePixelCount(originalImage.height)
buff.width = vImagePixelCount(originalImage.width)
buff.rowBytes = Int(buff.width) * (Int(expectedImageFormat.bitsPerPixel) + 7) / Int(expectedImageFormat.bitsPerComponent)
let bufferData = NSMutableData(length: Int(buff.height) * buff.rowBytes)!
buff.data = bufferData.mutableBytes
let initErr = vImageBuffer_InitWithCGImage(&buff, &expectedImageFormat, nil, originalImage, numericCast(kvImagePrintDiagnosticsToConsole | kvImageNoAllocate))
guard initErr == kvImageNoError else {
print("error creating image: \(initErr)")
abort()
}
var convertError = kvImageNoError
let convertedImageUnmanaged = vImageCreateCGImageFromBuffer(
&buff,
&expectedImageFormat,
nil, // callback
nil, // user data
numericCast(kvImagePrintDiagnosticsToConsole | kvImageNoAllocate),
&convertError
)
guard convertError == kvImageNoError else {
print("error converting image: \(convertError)")
abort()
}
let convertedImage = convertedImageUnmanaged!.takeRetainedValue()
// show the image – has vertical banding
// write it to a temp file
let tempBase = URL(fileURLWithPath:NSTemporaryDirectory())
let tempDir = tempBase.appendingPathComponent(UUID().uuidString, isDirectory: true)
try FileManager.default.createDirectory(at: tempDir, withIntermediateDirectories: true, attributes: nil)
let targetURL = tempDir.appendingPathComponent("result.tiff")
try NSImage(cgImage: convertedImage, size: .zero).tiffRepresentation?.write(to: targetURL)
print("Result image written to directory \(tempDir)")Environment:Xcode 11.3 (11C29)macOS 10.15.2 (19C57)In case anybody from Apple is watching, this is filed as FB7497362 and also contains the Playground bundle along with sample input and output images.
Post
Replies
Boosts
Views
Activity
My app has different layouts when in the iPad is in horizontal or in vertical orientation. It uses the size of the view controller to determine its orientation – regardless of the device's actual orientation (for example, the iPad Pro in split screen landscape mode would be in "portrait" mode since each half's height is larger than its width.I'm trying to create a launch storyboard for the app that shows its "blank state". However I'm having difficulties in setting up differing layout constraints for horizontal and vertical modes in the storyboard.In Xcode 11.4.1 I see only size classes and color gamut as criteria to activate/de-activate layout constraints. Similarly stack view's axis could only be differentiated by size classes. However iPad has the same size classes when shown in portrait or landscape. The size class only changes when the app is in split screen or slide-over mode.Is there a way to lay-out launch storyboards differently based on the orientation of the view?
I can’t seem to create any bot with Xcode 13 on macOS Monterey. The error message was “The server is currently unable to build for any platforms...”
The app I was trying to build was the standard macOS SwiftUI application, straight from the template code.
What seems to be the problem here?
Hi All,
After the upgrade to Xcode 13 final, I can’t seem to get Xcode Server to code sign my app in a bot. Error was always:
Warning: unable to build chain to self-signed root for signer "Apple Development: OS X Server (...)"
Building the app directly using Xcode interactively works though.
Xcode version: 13 (13A233)
macOS version: Monterey 12.0 Beta (21A5534d)