From c0bc013505610b5f0e2ec2555b0a41a78adb3ab7 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Fri, 25 Aug 2023 21:31:17 +0200 Subject: [PATCH] a few minor changes --- src/common/PNGLibrary.cxx | 4 +--- src/common/PNGLibrary.hxx | 2 +- src/emucore/Bezel.cxx | 20 ++++++++++++-------- src/gui/RomImageWidget.cxx | 3 +-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/common/PNGLibrary.cxx b/src/common/PNGLibrary.cxx index f9276df01..8a4ef0954 100644 --- a/src/common/PNGLibrary.cxx +++ b/src/common/PNGLibrary.cxx @@ -34,7 +34,7 @@ PNGLibrary::PNGLibrary(OSystem& osystem) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void PNGLibrary::loadImage(const string& filename, FBSurface& surface, - double* aspectRatio, VariantList& metaData) + VariantList& metaData) { png_structp png_ptr{nullptr}; png_infop info_ptr{nullptr}; @@ -123,8 +123,6 @@ void PNGLibrary::loadImage(const string& filename, FBSurface& surface, // Load image into the surface, setting the correct dimensions loadImagetoSurface(surface, hasAlpha); - *aspectRatio = static_cast(ReadInfo.width) / ReadInfo.height; - // Cleanup if(png_ptr) png_destroy_read_struct(&png_ptr, info_ptr ? &info_ptr : nullptr, nullptr); diff --git a/src/common/PNGLibrary.hxx b/src/common/PNGLibrary.hxx index 5af6526a2..a10e51d9a 100644 --- a/src/common/PNGLibrary.hxx +++ b/src/common/PNGLibrary.hxx @@ -50,7 +50,7 @@ class PNGLibrary error message. */ void loadImage(const string& filename, FBSurface& surface, - double* aspectRatio, VariantList& metaData); + VariantList& metaData); /** Save the current FrameBuffer image to a PNG file. Note that in most diff --git a/src/emucore/Bezel.cxx b/src/emucore/Bezel.cxx index 58dcdd5ae..214d707f9 100644 --- a/src/emucore/Bezel.cxx +++ b/src/emucore/Bezel.cxx @@ -80,7 +80,7 @@ uInt32 Bezel::borderSize(uInt32 x, uInt32 y, uInt32 size, Int32 step) const if(a < 255) return i; } - return size; + return size - 1; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -99,8 +99,6 @@ bool Bezel::load() if(isShown) { - double aspectRatio = 1; - mySurface = myFB.allocateSurface(1, 1); // dummy size try { @@ -114,17 +112,17 @@ bool Bezel::load() const string& name = getName(index); if(name != EmptyString) { + // Note: JPG does not support transparency imageName = path + name + ".png"; FSNode node(imageName); if(node.exists()) { isValid = true; + myOSystem.png().loadImage(imageName, *mySurface, metaData); break; } } } while(index != -1); - if(isValid) - myOSystem.png().loadImage(imageName, *mySurface, &aspectRatio, metaData); } catch(const runtime_error&) { @@ -154,9 +152,15 @@ bool Bezel::load() top = std::min(h, settings.getInt("bezel.topborder")); bottom = h - 1 - std::min(h, settings.getInt("bezel.bottomborder")); } - //cerr << right - left + 1 << " x " << bottom - top + 1 << " = " - // << double(right - left + 1) / double(bottom - top + 1); - myInfo = Info(Common::Size(w, h), Common::Rect(left, top, right, bottom)); + + cerr << (int)(right - left + 1) << " x " << (int)(bottom - top + 1) << " = " + << double((int)(right - left + 1)) / double((int)(bottom - top + 1)); + + // Disable bezel is no transparent window was found + if (left < right && top < bottom) + myInfo = Info(Common::Size(w, h), Common::Rect(left, top, right, bottom)); + else + myInfo = Info(); } else myInfo = Info(); diff --git a/src/gui/RomImageWidget.cxx b/src/gui/RomImageWidget.cxx index 501384cf2..856af7250 100644 --- a/src/gui/RomImageWidget.cxx +++ b/src/gui/RomImageWidget.cxx @@ -290,8 +290,7 @@ bool RomImageWidget::loadPng(const string& fileName) try { VariantList metaData; - double aspectRatio = 1; - instance().png().loadImage(fileName, *mySurface, &aspectRatio, metaData); + instance().png().loadImage(fileName, *mySurface, metaData); // Retrieve label for loaded image myLabel.clear();