Flip picture horizontal c++ without 2d array -


i know if there anyway horizontally flip image without use of 2d array. similar this:

     (int x = 0; x < width/2; x++) {                 (int y = 0; y < height; y++) {                    int temp = pixeldata[x][y];                     pixeldata[x][y]=pixeldata[width-x][y]                     pixeldata[width-x][y]=temp;                 }         } 

you can use single pointer image.

you need know distance (amount increment pointer) between end of 1 raster line (scanline) next. after increment past end of raster line, add distance pointer, end @ left column on next raster line.

with modern systems, have smart gpus, may have better efficiency copying image 2d-array, transforming it, putting back. smarter gpus may have mirroring function along bit-blitting.