The doc is fairly unhelpful and only states "The default byte order". Which could mean a few things.
I've done some experimentation and it appears that
kCGBitmapByteOrderDefault is kCGImageByteOrder32Big (even on my machine where kCGBitmapByteOrder32Host == kCGImageByteOrder32Little). But... can/should I rely on that? My guess would be "no" and that "default" really means "what Apple (currently) deems the default in the API to be". Otherwise the doc would state that (or "network order", etc).Interestingly, the API "knows" that it is 32Big because it successfully flips the byte order when you draw a
kCGBitmapByteOrderDefault image into a kCGImageByteOrder32Little context. It would be nice if it would report back what the underlying ordering actually is or if there was a call that would dynamically report the default byte order.Without those capabilities, I think I have the following options from a consuming perspective:
- Assume Default == 32Big with potential breakage later (which can admittedly be mitigated somewhat by unit tests)
- Write some one-time initialization code that examines the byte order when drawing to a 1-pixel context using
(assumes that the default is consistent across the system, and not per image).kCGBitmapByteOrderDefault - Redraw the image using a specified context (safe, but has a performance trade off)
For what it is worth, the reason I am looking at the raw underlying data is that I am loading the image data into an
Eigen::TensorMap.