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,
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<double>(ReadInfo.width) / ReadInfo.height;
// Cleanup
if(png_ptr)
png_destroy_read_struct(&png_ptr, info_ptr ? &info_ptr : nullptr, nullptr);

View File

@ -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

View File

@ -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();

View File

@ -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();