What does (0 << 12) mean in Swift?

In the docs, I found an enumeration case defined as:

kCGBitmapByteOrderDefault = (0 << 12)

As far as I know, this means that the bit shift is zero 12 times ... which is still zero. What am I missing?

+6
source share
3 answers

Per Apple Doc for CGBitmapInfo:

Byte order constants determine the byte order of pixel formats.

... If the code is spelled incorrectly, it can read the data incorrectly, which leads to incorrect display of colors or alpha.

Different constants for kCGBitmapByteOrderare mostly mapped to constants with the same name in CGImageByteOrder, which do not have "Default".

CGImageByteOrderInfo

, , , , , - 0, - 0, Rob , / .

, , :

kCGBitmapByteOrder16Little = (1 << 12) 16-, .

kCGBitmapByteOrder32Little = (2 << 12) 32-, .

kCGBitmapByteOrder16Big = (3 << 12) 16-, endian.

kCGBitmapByteOrder32Big = (4 << 12) 32-, .

16- 32- , .

" " (0 << 12) / 12. , , 12 . , " "

+1

, :

kCGBitmapByteOrderMask     = kCGImageByteOrderMask,
kCGBitmapByteOrderDefault  = (0 << 12),
kCGBitmapByteOrder16Little = kCGImageByteOrder16Little,
kCGBitmapByteOrder32Little = kCGImageByteOrder32Little,
kCGBitmapByteOrder16Big    = kCGImageByteOrder16Big,
kCGBitmapByteOrder32Big    = kCGImageByteOrder32Big

kCGBitmapByteOrderMask - 0x7000 (.. 12 ; 0b0111000000000000).

, 0 << 12 - " 12 0". , 0 << 12 0, , kCGBitmapByteOrderDefault , CGBitmapInfo ( 12 ), , 12 .

, , << 12 , .

+6

A design like this is meant either as the owner of the place, or documentation of a function that no longer supports it. This means that including a value kCGBitmapByteOrderDefaultin the summation will give the same value; therefore, it is intended for documentation purposes only.

0
source

All Articles