小编Ter*_*rry的帖子

如何对像素数据进行位条带化处理?

我有3个缓冲区,包含在32位处理器上运行的R,G,B位数据.

我需要以下列方式组合三个字节:

R[0] = 0b r1r2r3r4r5r6r7r8
G[0] = 0b g1g2g3g4g5g6g7g8
B[0] = 0b b1b2b3b4b5b6b7b8

int32_t Out = 0b r1g1b1r2g2b2r3g3 b3r4g4b4r5g5b5r6 g6b6r7g7b7r8g8b8 xxxxxxxx
Run Code Online (Sandbox Code Playgroud)

其中xxxxxxxx继续到缓冲区中的每个下一个字节.

我正在寻找一种最佳的组合方式.我的方法绝对没有效率.

这是我的方法

static void rgbcombineline(uint8_t line)
{
    uint32_t i, bit;
    uint8_t bitMask, rByte, gByte, bByte;
    uint32_t ByteExp, rgbByte;
    uint8_t *strPtr = (uint8_t*)&ByteExp;

    for (i = 0; i < (LCDpixelsCol / 8); i++)
    {
        rByte = rDispbuff[line][i];
        gByte = gDispbuff[line][i];
        bByte = bDispbuff[line][i];

        bitMask = 0b00000001;
        ByteExp = 0;
        for(bit = 0; bit < 8; bit++)
        {
            rgbByte …
Run Code Online (Sandbox Code Playgroud)

c bit-manipulation interleave

7
推荐指数
2
解决办法
206
查看次数

标签 统计

bit-manipulation ×1

c ×1

interleave ×1