RageSurfaceUtils::FlipVertically
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace RageSurfaceUtils
|
||||
RageSurface *MakeDummySurface( int height, int width );
|
||||
|
||||
void ApplyHotPinkColorKey( RageSurface *&img );
|
||||
void FlipVertically( RageSurface *img );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user