I'm trying to print, given a CGImageRef. In order to do this correctly, I need to get a couple of 'CGImageProperty' from my image, like kCGImagePropertyDPIHeight, kCGImagePropertyDPIWidth and kCGImagePropertyOrientation. I try to do this from a CGImageSourceRef, which I create in the following way:
where cgImage is my CGImageRef that I want to print. Once I get the CGImageSourceRef, I make a call to CGImageSourceCopyProperties() passing it the imageSource . But this always returns a NULL.
When I read an imageSource (and then the image) from a URL, and then call CGImageSourceCopyProperties(), it works fine and gives me the required properties. But I need it to work the other way around.
Am I using this function incorrectly? If so, how can I get the info I'm looking for from a CGImageRef?
Thanks for your time.
Code:
CGImageSourceRef imageSource = CGImageSourceCreateWithDataProvider(CGImageGetDataProvider(cgImage), NULL);
where cgImage is my CGImageRef that I want to print. Once I get the CGImageSourceRef, I make a call to CGImageSourceCopyProperties() passing it the imageSource . But this always returns a NULL.
When I read an imageSource (and then the image) from a URL, and then call CGImageSourceCopyProperties(), it works fine and gives me the required properties. But I need it to work the other way around.
Am I using this function incorrectly? If so, how can I get the info I'm looking for from a CGImageRef?
Thanks for your time.