0
Ich habe eine Aufgabe zu drehen und skalieren ein BMP-Bild in C. Der Code zum Spiegeln eines Bildes wurde uns gegeben, um uns zu verstehen, wie es funktioniert, aber ich habe eine schwere Zeit damit.Code zum Umdrehen eines BMP-Bildes in C
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;
}
Mein Beileid. Hattest du eine Frage? –
Kleinere Ausgabe: Für _large_ Bilder besser 'sizeof (PIXEL) * rows * cols'. Ich nehme an, deine Bilder sind <2G Pixel. – chux