Fast Converting RGBA to ARGB

后端 未结 4 915
半阙折子戏
半阙折子戏 2020-12-18 08:16

I am trying to convert a rgba buffer into argb, is there any way to improve the next algorithm, or any other faster way to perform such operation? Taking into account that t

4条回答
  •  旧巷少年郎
    2020-12-18 09:05

    I will focus only in the swap function:

    typedef unsigned int Color32;
    
    inline Color32 Color32Reverse(Color32 x)
    {
    
        return
        // Source is in format: 0xAARRGGBB
            ((x & 0xFF000000) >> 24) | //______AA
            ((x & 0x00FF0000) >>  8) | //____RR__
            ((x & 0x0000FF00) <<  8) | //__GG____
            ((x & 0x000000FF) << 24);  //BB______
        // Return value is in format:  0xBBGGRRAA
    }
    

提交回复
热议问题