diff --git a/src/common/FrameBufferSDL2.hxx b/src/common/FrameBufferSDL2.hxx index 64803e6bb..857891685 100644 --- a/src/common/FrameBufferSDL2.hxx +++ b/src/common/FrameBufferSDL2.hxx @@ -137,12 +137,12 @@ class FrameBufferSDL2 : public FrameBuffer /** Transform from window to renderer coordinates, x direction */ - int scaleX(int x) const { return (x * myRenderW) / myWindowW; } + int scaleX(int x) const override { return (x * myRenderW) / myWindowW; } /** Transform from window to renderer coordinates, y direction */ - int scaleY(int y) const { return (y * myRenderH) / myWindowH; } + int scaleY(int y) const override { return (y * myRenderH) / myWindowH; } protected: ////////////////////////////////////////////////////////////////////// diff --git a/src/common/PNGLibrary.cxx b/src/common/PNGLibrary.cxx index 779f6b0f6..e1980a975 100644 --- a/src/common/PNGLibrary.cxx +++ b/src/common/PNGLibrary.cxx @@ -29,6 +29,7 @@ #include "TIASurface.hxx" #include "Version.hxx" #include "PNGLibrary.hxx" +#include "Rect.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PNGLibrary::PNGLibrary(OSystem& osystem) @@ -129,7 +130,13 @@ void PNGLibrary::saveImage(const string& filename, const VariantList& comments) throw runtime_error("ERROR: Couldn't create snapshot file"); const FrameBuffer& fb = myOSystem.frameBuffer(); - const Common::Rect& rect = fb.imageRect(); + + const Common::Rect& rectUnscaled = fb.imageRect(); + const Common::Rect rect( + Common::Point(fb.scaleX(rectUnscaled.x()), fb.scaleY(rectUnscaled.y())), + fb.scaleX(rectUnscaled.w()), fb.scaleY(rectUnscaled.h()) + ); + png_uint_32 width = rect.w(), height = rect.h(); // Get framebuffer pixel data (we get ABGR format) diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index ce215345a..67628ee84 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -381,6 +381,16 @@ class FrameBuffer */ virtual void clear() = 0; + /** + Transform from window to renderer coordinates, x direction + */ + virtual int scaleX(int x) const { return x; } + + /** + Transform from window to renderer coordinates, y direction + */ + virtual int scaleY(int y) const { return y; } + protected: /** This method is called to query and initialize the video hardware