0
Cでbmp画像を回転して拡大/縮小するという割り当てがあります。画像を反転させるコードが与えられていますが、そうするのは苦労します。Cでbmp画像を反転するコードを理解する
int flip (PIXEL *original, PIXEL **new, int rows, int cols)
{
int row, col;
if ((rows <= 0) || (cols <= 0)) return -1;
*new = (PIXEL*)malloc(rows*cols*sizeof(PIXEL));
for (row=0; row < rows; row++)
for (col=0; col < cols; col++) {
PIXEL* o = original + row*cols + col;
PIXEL* n = (*new) + row*cols + (cols-1-col);
*n = *o;
}
return 0;
}
私の哀悼の意を。あなたは質問がありましたか? –
マイナーな問題:_large_ピクチャでは、 'sizeof(PIXEL)* rows * cols'を使う方が良いです。私はあなたの写真が<2Gピクセルであると仮定します。 – chux