场景:
C/C++语言,将画面旋转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;
}
}
}
}