IKPictureTaker return the abnormal image

IKPictureTaker return the abnormal image.

the step: step 1: select image from other, click down. step 2: select the same image from recents.

the result: return the abnormal image from a recents selection of photos, but it can only be reproduced under certain images and certain macOS version(eg: OS 10.15.6 / 11.2.3 / 11.6).

The certain picture are attached.

Replies

the abnormal image as follows:

You can see the white color of the picture

the simple code as follow:

    
    // see xcdoc://?url=developer.apple.com/library/etc/redirect/xcode/mac/34580/documentation/GraphicsImaging/Conceptual/ImageKitProgrammingGuide/ImageBrowser/ImageBrowser.html
    func setCommonValuesForKeys(allowsVideoCapture: Bool) {
        /* use - (void) setValue:(id)aValue forKey:(id) aKey (NSKeyValueCoding) to customize the pictureTaker panel appearance and behaviors
         *
         *   <key>                                    <class>                         <default>
         *   IKPictureTakerAllowsVideoCaptureKey      NSNumber(BOOL)                    YES
         *   IKPictureTakerAllowsFileChoosingKey      NSNumber(BOOL)                    YES
         *   IKPictureTakerShowRecentPictureKey          NSNumber(BOOL)                    YES
         *   IKPictureTakerUpdateRecentPictureKey     NSNumber(BOOL)                    YES
         *   IKPictureTakerAllowsEditingKey           NSNumber(BOOL)                    YES
         *   IKPictureTakerShowEffectsKey              NSNumber(BOOL)                    NO
         *   IKPictureTakerInformationalTextKey          NSString or NSAttributedString    "Drag Image Here"
         *   IKPictureTakerImageTransformsKey         NSDictionary(serializable)        none
         *   IKPictureTakerOutputImageMaxSizeKey      NSValue(NSSize)                    none
         *   IKPictureTakerShowAddressBookPictureKey  NSNumber(BOOL)                    NO
         *   IKPictureTakerShowEmptyPictureKey        NSImage                            nil
         *   IKPictureTakerRemainOpenAfterValidateKey NSNumber(BOOL)                    NO
         */
        IKPictureTaker.pictureTaker().setValuesForKeys(
            [
                IKPictureTakerShowEffectsKey: NSNumber(booleanLiteral: true),
                IKPictureTakerAllowsVideoCaptureKey: NSNumber(booleanLiteral: allowsVideoCapture),
                IKPictureTakerAllowsFileChoosingKey: NSNumber(booleanLiteral: true),
                IKPictureTakerShowRecentPictureKey: NSNumber(booleanLiteral: true),
                IKPictureTakerUpdateRecentPictureKey: NSNumber(booleanLiteral: true),
                IKPictureTakerAllowsEditingKey: NSNumber(booleanLiteral: true),
                IKPictureTakerImageTransformsKey: NSDictionary(),
                IKPictureTakerShowAddressBookPictureKey: NSNumber(booleanLiteral: true),
                IKPictureTakerShowEmptyPictureKey: nil,
                IKPictureTakerInformationalTextKey: "Drop an Image Here",
                IKPictureTakerOutputImageMaxSizeKey: NSValue(size: NSSize(width: 40000, height: 40000))
            ]
        )
    }

    func closeForInstance(_ instance: Any?) {
        guard let instance = instance, isPointForInstance(instance) else { return }
        close()
    }
    
    private func isPointForInstance(_ instance: Any) -> Bool {
        guard let currentDelegate = delegate else { return false }
        return instance as AnyObject === currentDelegate as AnyObject
    }
}

class ViewController: NSViewController {

    @IBOutlet weak var xx: NSImageView!
    @IBOutlet weak var imageV: NSImageView!
    @IBOutlet weak var btn: NSButton!
    
    @IBAction func btnH(_ sender: NSButton) {
        IKPictureTaker.pictureTaker().popUpRecentsMenu(
            for: sender,
            withDelegate: self,
            didEnd: #selector(pictureTakerDidEnd(_:returnCode:contextInfo:)),
            contextInfo: nil
        )
    }
    
    @objc func pictureTakerDidEnd(_ pictureTaker: IKPictureTaker, returnCode: Int, contextInfo: Any?) {
        guard returnCode == NSApplication.ModalResponse.OK.rawValue,
              let image = pictureTaker.outputImage() else { return }
        xx.image = image
    }

}