I assume the vector pixels
represents each row in your matrix. Then to flip all values in the vector, you can simply use std::reverse_copy
like this:
std::vector<uint8_t> flippy;
flippy.resize(pixels.size());
std::reverse_copy(pixels.begin(), pixels.end(), flippy.begin());
You need to do this for each row. You can then output each flipped row after each reverse so that the vector 'flippy' only represents the current row in operation.