Most code that creates a bitmap context uses kCGImageAlphaPremultipliedFirst, to create ARGB, instead of kCGImageAlphaPremultipliedLast to create RGBA. Is there a reason ARGB is preferred?

(the usage):

CGBitmapContextCreate(NULL, size.width, size.height, 8, size.width * 4, 
    colorSpace, kCGImageAlphaPremultipliedFirst);
2

There are 2 answers

1
Vignesh On

I think it has got something to do with 'endian-ness' of the CPU used.

0
ldindu On

The above two constants specify the location of the alpha component and whether the color components are premultiplied. It could be stored in the most or least significant bits of each pixel, other than that both constants perform equally there is no preference over one another in term of performance.

For bitmaps created in iOS 3.2 and later, the drawing environment uses the premultiplied ARGB format to store the bitmap data. For bitmaps created in iOS 3.1.x and earlier, the drawing environment uses the premultiplied RGBA format to store the bitmap data.