aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--graphics/surface.cpp14
-rw-r--r--graphics/surface.h7
2 files changed, 21 insertions, 0 deletions
diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index 265249e72f..26d40b8922 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -354,6 +354,20 @@ void Surface::move(int dx, int dy, int height) {
}
}
+void Surface::flipVertical(const Common::Rect &r) {
+ const int width = r.width() * format.bytesPerPixel;
+ byte *temp = new byte[width];
+ for (int y = r.top; y < r.bottom / 2; y++) {
+ byte *row1 = (byte *)getBasePtr(r.left, y);
+ byte *row2 = (byte *)getBasePtr(r.left, r.bottom - y - 1);
+
+ memcpy(temp, row1, width);
+ memcpy(row1, row2, width);
+ memcpy(row2, temp, width);
+ }
+ delete[] temp;
+}
+
void Surface::convertToInPlace(const PixelFormat &dstFormat, const byte *palette) {
// Do not convert to the same format and ignore empty surfaces.
if (format == dstFormat || pixels == 0) {
diff --git a/graphics/surface.h b/graphics/surface.h
index 19107b8bab..8728106273 100644
--- a/graphics/surface.h
+++ b/graphics/surface.h
@@ -327,6 +327,13 @@ public:
// See comment in graphics/surface.cpp about it
void move(int dx, int dy, int height);
+
+ /**
+ * Flip the specified rect vertically.
+ *
+ * @param r Rect to flip
+ */
+ void flipVertical(const Common::Rect &r);
};
/**