場(chǎng)景:
C/C++語(yǔ)言,將畫(huà)面旋轉(zhuǎn)90度(不是性?xún)r(jià)比最高)。
相關(guān)代碼如下:
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;
}
}
}
}