How do you flip screenshots?

Started by Jonathan_NL, November 30, 2004, 06:21:48 AM

Previous topic - Next topic

Jonathan_NL

Just wondering how you do it... I just 'invented' this:
Code Sample
char *row = malloc(width*3);
for(y=0; y<height/2; y++) {
memcpy(row, pix+y*width*3, width*3);
memcpy(pix+y*width*3, pix+(height-y-1)*width*3, width*3);
memcpy(pix+(height-y-1)*width*3, row, width*3);
}
free(row);

It can probably be done faster (after edit I'm not sure), but hey, it works, I made it in 3 seconds or so and it doesn't use much RAM. :-)

Another edit: you can also write the lines in opposite order of course. Not sure how fast that is...
I rarely check this forum anymore. Feel free to send me a PM if you want my attention.