diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index 0f1807b5a2..0aef732706 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -830,17 +830,8 @@ RageSurface* RageDisplay_OGL::CreateScreenshot() GL_UNSIGNED_BYTE, image->pixels); AssertNoGLError(); - // flip vertically - int pitch = image->pitch; - int bytes_per_row = image->format->BytesPerPixel * width; - char *row = new char[bytes_per_row]; - for( int y=0; yGetVideoModeParams().height/2; y++ ) - { - memcpy( row, (char *)image->pixels + pitch * y, bytes_per_row ); - memcpy( (char *)image->pixels + pitch * y, (char *)image->pixels + pitch * (height-1-y), bytes_per_row ); - memcpy( (char *)image->pixels + pitch * (height-1-y), row, bytes_per_row ); - } - delete [] row; + RageSurfaceUtils::FlipVertically( image ); + return image; } diff --git a/stepmania/src/RageSurfaceUtils.cpp b/stepmania/src/RageSurfaceUtils.cpp index f58934d1c4..f3378346c3 100644 --- a/stepmania/src/RageSurfaceUtils.cpp +++ b/stepmania/src/RageSurfaceUtils.cpp @@ -950,6 +950,23 @@ void RageSurfaceUtils::ApplyHotPinkColorKey( RageSurface *&img ) } } +void RageSurfaceUtils::FlipVertically( RageSurface *img ) +{ + const int pitch = img->pitch; + const int bytes_per_row = img->format->BytesPerPixel * img->w; + char *row = new char[bytes_per_row]; + + for( int y=0; y < img->h/2; y++ ) + { + int y2 = img->h-1-y; + memcpy( row, img->pixels + pitch * y, bytes_per_row ); + memcpy( img->pixels + pitch * y, img->pixels + pitch * y2, bytes_per_row ); + memcpy( img->pixels + pitch * y2, row, bytes_per_row ); + } + + delete [] row; +} + /* * (c) 2001-2004 Glenn Maynard, Chris Danford * All rights reserved. diff --git a/stepmania/src/RageSurfaceUtils.h b/stepmania/src/RageSurfaceUtils.h index 904c7d68e7..85f0bca866 100644 --- a/stepmania/src/RageSurfaceUtils.h +++ b/stepmania/src/RageSurfaceUtils.h @@ -57,6 +57,7 @@ namespace RageSurfaceUtils RageSurface *MakeDummySurface( int height, int width ); void ApplyHotPinkColorKey( RageSurface *&img ); + void FlipVertically( RageSurface *img ); }; #endif