a few minor changes

This commit is contained in:
thrust26 2023-08-25 21:31:17 +02:00
parent a5b394ab5f
commit 8dac721a65
4 changed files with 15 additions and 14 deletions

View File

@ -34,7 +34,7 @@ PNGLibrary::PNGLibrary(OSystem& osystem)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::loadImage(const string& filename, FBSurface& surface, void PNGLibrary::loadImage(const string& filename, FBSurface& surface,
double* aspectRatio, VariantList& metaData) VariantList& metaData)
{ {
png_structp png_ptr{nullptr}; png_structp png_ptr{nullptr};
png_infop info_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 // Load image into the surface, setting the correct dimensions
loadImagetoSurface(surface, hasAlpha); loadImagetoSurface(surface, hasAlpha);
*aspectRatio = static_cast<double>(ReadInfo.width) / ReadInfo.height;
// Cleanup // Cleanup
if(png_ptr) if(png_ptr)
png_destroy_read_struct(&png_ptr, info_ptr ? &info_ptr : nullptr, nullptr); png_destroy_read_struct(&png_ptr, info_ptr ? &info_ptr : nullptr, nullptr);

View File

@ -50,7 +50,7 @@ class PNGLibrary
error message. error message.
*/ */
void loadImage(const string& filename, FBSurface& surface, 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 Save the current FrameBuffer image to a PNG file. Note that in most

View File

@ -80,7 +80,7 @@ uInt32 Bezel::borderSize(uInt32 x, uInt32 y, uInt32 size, Int32 step) const
if(a < 255) if(a < 255)
return i; return i;
} }
return size; return size - 1;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -99,8 +99,6 @@ bool Bezel::load()
if(isShown) if(isShown)
{ {
double aspectRatio = 1;
mySurface = myFB.allocateSurface(1, 1); // dummy size mySurface = myFB.allocateSurface(1, 1); // dummy size
try try
{ {
@ -114,17 +112,17 @@ bool Bezel::load()
const string& name = getName(index); const string& name = getName(index);
if(name != EmptyString) if(name != EmptyString)
{ {
// Note: JPG does not support transparency
imageName = path + name + ".png"; imageName = path + name + ".png";
FSNode node(imageName); FSNode node(imageName);
if(node.exists()) if(node.exists())
{ {
isValid = true; isValid = true;
myOSystem.png().loadImage(imageName, *mySurface, metaData);
break; break;
} }
} }
} while(index != -1); } while(index != -1);
if(isValid)
myOSystem.png().loadImage(imageName, *mySurface, &aspectRatio, metaData);
} }
catch(const runtime_error&) catch(const runtime_error&)
{ {
@ -154,9 +152,15 @@ bool Bezel::load()
top = std::min(h, settings.getInt("bezel.topborder")); top = std::min(h, settings.getInt("bezel.topborder"));
bottom = h - 1 - std::min(h, settings.getInt("bezel.bottomborder")); 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); cerr << (int)(right - left + 1) << " x " << (int)(bottom - top + 1) << " = "
myInfo = Info(Common::Size(w, h), Common::Rect(left, top, right, bottom)); << 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 else
myInfo = Info(); myInfo = Info();

View File

@ -290,8 +290,7 @@ bool RomImageWidget::loadPng(const string& fileName)
try try
{ {
VariantList metaData; VariantList metaData;
double aspectRatio = 1; instance().png().loadImage(fileName, *mySurface, metaData);
instance().png().loadImage(fileName, *mySurface, &aspectRatio, metaData);
// Retrieve label for loaded image // Retrieve label for loaded image
myLabel.clear(); myLabel.clear();