Skip to content

Instantly share code, notes, and snippets.

@adventureloop
Created May 14, 2013 17:53
Show Gist options
  • Save adventureloop/5578011 to your computer and use it in GitHub Desktop.
Save adventureloop/5578011 to your computer and use it in GitHub Desktop.
void Texture::flipImageData(unsigned char *data,int width,int height)
{
int x,y;
int size = (width * height)-1; //Indices start at 0
width = (width < 0) ? 0 : width;
height = (height < 0) ? 0 : height;
cout << "Image width: " << width << " height: " << height << endl;
for(y = 0; y < height/2;y++) {
cout << "y: " << y << " height - y " << height - y << endl;
for(x = 0; x < width;x++) {
int bottom = (width*y) + x;
int top = (width*(height-y)) + x;
unsigned char tmp = data[bottom];
data[bottom] = data[top];
data[top] = tmp;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment