Skip to content

Instantly share code, notes, and snippets.

@SubhiH
Created December 26, 2018 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SubhiH/a9ac5a6dbb33e41c394d94d66593c3d1 to your computer and use it in GitHub Desktop.
Save SubhiH/a9ac5a6dbb33e41c394d94d66593c3d1 to your computer and use it in GitHub Desktop.
Rotate an image
void ImageOperator::rotate(const unsigned char* input,
const int width,
const int height,
const int channel,
unsigned char*& output){
unsigned char* tmp = new unsigned char[width*height*channel];
int step = channel*width;
for (int row = 0; row < height; ++row) {
for (int col = 0; col < width*channel; col+=channel) {
for (int chan = 0; chan < channel; ++chan) {
tmp[(col/channel)*step+(step-row*channel-1)+chan-(channel-1)] = input[row*step+col+chan];
}
}
}
output = tmp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment