1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-13 13:18:43 +02:00

missing prescalefactor

This commit is contained in:
Laserlicht 2024-11-08 00:09:17 +01:00 committed by GitHub
parent bcdef11093
commit 1f7cec3ae3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 7 deletions

View File

@ -102,12 +102,12 @@ SDLImageShared::SDLImageShared(const CDefFile * data, size_t frame, size_t group
savePalette();
}
SDLImageShared::SDLImageShared(SDL_Surface * from)
SDLImageShared::SDLImageShared(SDL_Surface * from, int preScaleFactor)
: surf(nullptr),
margins(0, 0),
fullSize(0, 0),
originalPalette(nullptr),
preScaleFactor(1)
preScaleFactor(preScaleFactor)
{
surf = from;
if (surf == nullptr)
@ -285,7 +285,7 @@ std::shared_ptr<ISharedImage> SDLImageShared::scaleInteger(int factor, SDL_Palet
else
scaled = CSDL_Ext::scaleSurface(surf, (surf->w / preScaleFactor) * factor, (surf->h / preScaleFactor) * factor);
auto ret = std::make_shared<SDLImageShared>(scaled);
auto ret = std::make_shared<SDLImageShared>(scaled, preScaleFactor);
ret->fullSize.x = fullSize.x * factor;
ret->fullSize.y = fullSize.y * factor;
@ -320,7 +320,7 @@ std::shared_ptr<ISharedImage> SDLImageShared::scaleTo(const Point & size, SDL_Pa
else
CSDL_Ext::setDefaultColorKey(scaled);//just in case
auto ret = std::make_shared<SDLImageShared>(scaled);
auto ret = std::make_shared<SDLImageShared>(scaled, preScaleFactor);
ret->fullSize.x = (int) round((float)fullSize.x * scaleX);
ret->fullSize.y = (int) round((float)fullSize.y * scaleY);
@ -378,7 +378,7 @@ std::shared_ptr<IImage> SDLImageShared::createImageReference(EImageBlitMode mode
std::shared_ptr<ISharedImage> SDLImageShared::horizontalFlip() const
{
SDL_Surface * flipped = CSDL_Ext::horizontalFlip(surf);
auto ret = std::make_shared<SDLImageShared>(flipped);
auto ret = std::make_shared<SDLImageShared>(flipped, preScaleFactor);
ret->fullSize = fullSize;
ret->margins.x = margins.x;
ret->margins.y = fullSize.y - surf->h - margins.y;
@ -390,7 +390,7 @@ std::shared_ptr<ISharedImage> SDLImageShared::horizontalFlip() const
std::shared_ptr<ISharedImage> SDLImageShared::verticalFlip() const
{
SDL_Surface * flipped = CSDL_Ext::verticalFlip(surf);
auto ret = std::make_shared<SDLImageShared>(flipped);
auto ret = std::make_shared<SDLImageShared>(flipped, preScaleFactor);
ret->fullSize = fullSize;
ret->margins.x = fullSize.x - surf->w - margins.x;
ret->margins.y = margins.y;

View File

@ -49,7 +49,7 @@ public:
//Load from bitmap file
SDLImageShared(const ImagePath & filename, int preScaleFactor=1);
//Create using existing surface, extraRef will increase refcount on SDL_Surface
SDLImageShared(SDL_Surface * from);
SDLImageShared(SDL_Surface * from, int preScaleFactor=1);
~SDLImageShared();
void draw(SDL_Surface * where, SDL_Palette * palette, const Point & dest, const Rect * src, const ColorRGBA & colorMultiplier, uint8_t alpha, EImageBlitMode mode) const override;