mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
IMAGE: Eliminate code difference by using flip operation from surface class.
This commit is contained in:
@@ -742,10 +742,11 @@ bool OpenGLSdlGraphicsManager::saveScreenshot(const Common::String &filename) co
|
||||
#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
|
||||
}
|
||||
|
||||
|
||||
+5
-13
@@ -132,8 +132,7 @@ bool BitmapDecoder::loadStream(Common::SeekableReadStream &stream) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// ResidualVM specific argument: bottomUp
|
||||
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,17 +169,10 @@ bool writeBMP(Common::WriteStream &out, const Graphics::Surface &input, const bo
|
||||
out.writeUint32LE(0);
|
||||
out.writeUint32LE(0);
|
||||
|
||||
// ResidualVM specific
|
||||
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
|
||||
|
||||
+1
-2
@@ -70,8 +70,7 @@ private:
|
||||
/**
|
||||
* Outputs an uncompressed BMP stream of the given input surface.
|
||||
*/
|
||||
// ResidualVM specific argument: bottomUp
|
||||
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
|
||||
|
||||
|
||||
+3
-11
@@ -255,8 +255,7 @@ bool PNGDecoder::loadStream(Common::SeekableReadStream &stream) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// ResidualVM specific argument: bottomUp
|
||||
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);
|
||||
@@ -309,15 +308,8 @@ bool writePNG(Common::WriteStream &out, const Graphics::Surface &input, const bo
|
||||
|
||||
Common::Array<const uint8 *> rows;
|
||||
rows.reserve(surface->h);
|
||||
// ResidualVM specific
|
||||
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()));
|
||||
|
||||
+1
-2
@@ -79,8 +79,7 @@ private:
|
||||
/**
|
||||
* Outputs a compressed PNG stream of the given input surface.
|
||||
*/
|
||||
// ResidualVM specific argument: bottomUp
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user