Graphics: Add flipHorizontal to Surface
This complements flipVertical and is needed for the AGS engine.
This commit is contained in:
parent
54e99b36e9
commit
31d76cd039
2 changed files with 20 additions and 0 deletions
|
@ -419,6 +419,19 @@ void Surface::flipVertical(const Common::Rect &r) {
|
|||
delete[] temp;
|
||||
}
|
||||
|
||||
void Surface::flipHorizontal(const Common::Rect &r) {
|
||||
uint32 tmp = 0;
|
||||
const int width = r.width() * format.bytesPerPixel;
|
||||
for (int y = r.top; y < r.bottom; ++y) {
|
||||
byte *row = (byte *)getBasePtr(r.left, y);
|
||||
for (int x = 0; x < width / 2; x += format.bytesPerPixel) {
|
||||
memcpy(&tmp, row + x, format.bytesPerPixel);
|
||||
memcpy(row + x, row + width - format.bytesPerPixel - x, format.bytesPerPixel);
|
||||
memcpy(row + width - format.bytesPerPixel - x, &tmp, format.bytesPerPixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Graphics::Surface *Surface::scale(int16 newWidth, int16 newHeight, bool filtering) const {
|
||||
Graphics::Surface *target = new Graphics::Surface();
|
||||
|
||||
|
|
|
@ -446,6 +446,13 @@ public:
|
|||
*/
|
||||
void flipVertical(const Common::Rect &r);
|
||||
|
||||
/**
|
||||
* Flip the specified rect horizontally.
|
||||
*
|
||||
* @param r The rectangle to flip.
|
||||
*/
|
||||
void flipHorizontal(const Common::Rect &r);
|
||||
|
||||
/**
|
||||
* Scale the data to the given size.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue