RageSurfaceUtils::FlipVertically

This commit is contained in:
Glenn Maynard
2004-08-26 20:36:44 +00:00
parent d2ad8869f0
commit 1771747c0c
3 changed files with 20 additions and 11 deletions
+2 -11
View File
@@ -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; y<wind->GetVideoModeParams().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;
}
+17
View File
@@ -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.
+1
View File
@@ -57,6 +57,7 @@ namespace RageSurfaceUtils
RageSurface *MakeDummySurface( int height, int width );
void ApplyHotPinkColorKey( RageSurface *&img );
void FlipVertically( RageSurface *img );
};
#endif