aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCameron Cawley2019-12-19 21:22:42 +0000
committerFilippos Karapetis2020-01-02 20:53:29 +0200
commitd289fa5f981930d151c4d7d57fc5bed1dac63750 (patch)
tree46c2778613b40c29fb87e979d35e2188fca93368
parentba035ac532a65457d55ec77b06273642d5191909 (diff)
downloadscummvm-rg350-d289fa5f981930d151c4d7d57fc5bed1dac63750.tar.gz
scummvm-rg350-d289fa5f981930d151c4d7d57fc5bed1dac63750.tar.bz2
scummvm-rg350-d289fa5f981930d151c4d7d57fc5bed1dac63750.zip
OPENGL: Ensure surfaces created by saveScreenshot are the right way up
-rw-r--r--backends/graphics/opengl/opengl-graphics.cpp6
-rw-r--r--image/bmp.cpp15
-rw-r--r--image/bmp.h5
-rw-r--r--image/png.cpp12
-rw-r--r--image/png.h5
5 files changed, 13 insertions, 30 deletions
diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp
index a01047e268..dfc8448d14 100644
--- a/backends/graphics/opengl/opengl-graphics.cpp
+++ b/backends/graphics/opengl/opengl-graphics.cpp
@@ -1323,10 +1323,12 @@ bool OpenGLGraphicsManager::saveScreenshot(const Common::String &filename) const
#endif
Graphics::Surface data;
data.init(width, height, lineSize, &pixels.front(), format);
+ data.flipVertical(Common::Rect(width, height));
+
#ifdef USE_PNG
- return Image::writePNG(out, data, true);
+ return Image::writePNG(out, data);
#else
- return Image::writeBMP(out, data, true);
+ return Image::writeBMP(out, data);
#endif
}
diff --git a/image/bmp.cpp b/image/bmp.cpp
index bd3381d26c..6d69094eeb 100644
--- a/image/bmp.cpp
+++ b/image/bmp.cpp
@@ -132,7 +132,7 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
return true;
}
-bool writeBMP(Common::WriteStream &out, const Graphics::Surface &input, const bool bottomUp) {
+bool writeBMP(Common::WriteStream &out, const Graphics::Surface &input) {
#ifdef SCUMM_LITTLE_ENDIAN
const Graphics::PixelFormat requiredFormat_3byte(3, 8, 8, 8, 0, 16, 8, 0, 0);
#else
@@ -170,16 +170,9 @@ bool writeBMP(Common::WriteStream &out, const Graphics::Surface &input, const bo
out.writeUint32LE(0);
- if (bottomUp) {
- for (uint y = 0; y < surface->h; ++y) {
- out.write((const void *)surface->getBasePtr(0, y), dstPitch);
- out.write(&padding, extraDataLength);
- }
- } else {
- for (uint y = surface->h; y-- > 0;) {
- out.write((const void *)surface->getBasePtr(0, y), dstPitch);
- out.write(&padding, extraDataLength);
- }
+ for (uint y = surface->h; y-- > 0;) {
+ out.write((const void *)surface->getBasePtr(0, y), dstPitch);
+ out.write(&padding, extraDataLength);
}
// free tmp surface
diff --git a/image/bmp.h b/image/bmp.h
index a23f1e0978..2b7d6fb83f 100644
--- a/image/bmp.h
+++ b/image/bmp.h
@@ -69,11 +69,8 @@ private:
/**
* Outputs an uncompressed BMP stream of the given input surface.
- *
- * @param bottomUp Flip the vertical axis so pixel data is drawn from the
- * bottom up, instead of from the top down.
*/
-bool writeBMP(Common::WriteStream &out, const Graphics::Surface &input, const bool bottomUp = false);
+bool writeBMP(Common::WriteStream &out, const Graphics::Surface &input);
} // End of namespace Image
diff --git a/image/png.cpp b/image/png.cpp
index 9532840f2f..1072d41a18 100644
--- a/image/png.cpp
+++ b/image/png.cpp
@@ -255,7 +255,7 @@ bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
#endif
}
-bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const bool bottomUp) {
+bool writePNG(Common::WriteStream &out, const Graphics::Surface &input) {
#ifdef USE_PNG
#ifdef SCUMM_LITTLE_ENDIAN
const Graphics::PixelFormat requiredFormat_3byte(3, 8, 8, 8, 0, 0, 8, 16, 0);
@@ -300,14 +300,8 @@ bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const bo
Common::Array<const uint8 *> rows;
rows.reserve(surface->h);
- if (bottomUp) {
- for (uint y = surface->h; y-- > 0;) {
- rows.push_back((const uint8 *)surface->getBasePtr(0, y));
- }
- } else {
- for (uint y = 0; y < surface->h; ++y) {
- rows.push_back((const uint8 *)surface->getBasePtr(0, y));
- }
+ for (uint y = 0; y < surface->h; ++y) {
+ rows.push_back((const uint8 *)surface->getBasePtr(0, y));
}
png_set_rows(pngPtr, infoPtr, const_cast<uint8 **>(&rows.front()));
diff --git a/image/png.h b/image/png.h
index f983da467e..1402976963 100644
--- a/image/png.h
+++ b/image/png.h
@@ -78,11 +78,8 @@ private:
/**
* Outputs a compressed PNG stream of the given input surface.
- *
- * @param bottomUp Flip the vertical axis so pixel data is drawn from the
- * bottom up, instead of from the top down.
*/
-bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const bool bottomUp = false);
+bool writePNG(Common::WriteStream &out, const Graphics::Surface &input);
} // End of namespace Image