顺时针旋转RGBA图片90度

void RotateRGBA(
    const sd_uint8* src,
    sd_uint8* result,
    int width,
    int height,
    int mode
    ){// mode 0 -> 0; 1 -> 90; 2->180; 3->270;
    if(mode == 1){
        int x = 0;
        int y = 0;
        int posR = 0;
        int posS = 0;
        for(x = 0; x < width; x++){
            for(y = height - 1; y >= 0; y--){
                posS = (y * width + x) * 4;
                result[posR + 0] = src[posS + 0];// R
                result[posR + 1] = src[posS + 1];// G
                result[posR + 2] = src[posS + 2];// B
                result[posR + 3] = src[posS + 3];// A
                posR += 4;
            }
        }
    }
}

猜你喜欢

转载自blog.csdn.net/qq_21743659/article/details/129531726