1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00
vcmi/client/renderSDL/ImageScaled.h

66 lines
2.0 KiB
C++
Raw Normal View History

2024-07-21 23:11:02 +02:00
/*
* ImageScaled.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#pragma once
#include "../render/IImage.h"
#include "../render/IRenderHandler.h"
2024-07-21 23:11:02 +02:00
#include "../../lib/Color.h"
#include "../../lib/constants/EntityIdentifiers.h"
2024-07-21 23:11:02 +02:00
struct SDL_Palette;
class SDLImageShared;
2024-07-21 23:11:02 +02:00
// Upscaled image with several mechanisms to emulate H3 palette effects
class ImageScaled final : public IImage
2024-07-21 23:11:02 +02:00
{
private:
2024-07-21 23:11:02 +02:00
/// Original unscaled image
std::shared_ptr<const ISharedImage> source;
2024-07-21 23:11:02 +02:00
/// Upscaled shadow of our image, may be null
std::shared_ptr<const ISharedImage> shadow;
2024-07-21 23:11:02 +02:00
/// Upscaled main part of our image, may be null
std::shared_ptr<const ISharedImage> body;
2024-07-21 23:11:02 +02:00
/// Upscaled overlay (player color, selection highlight) of our image, may be null
std::shared_ptr<const ISharedImage> overlay;
ImageLocator locator;
ColorRGBA colorMultiplier;
PlayerColor playerColor = PlayerColor::CANNOT_DETERMINE;
2024-07-21 23:11:02 +02:00
uint8_t alphaValue;
EImageBlitMode blitMode;
void prepareImages();
2024-07-21 23:11:02 +02:00
public:
ImageScaled(const ImageLocator & locator, const std::shared_ptr<const ISharedImage> & source, EImageBlitMode mode);
2024-07-21 23:11:02 +02:00
void scaleInteger(int factor) override;
void scaleTo(const Point & size) override;
2024-07-21 23:11:02 +02:00
void exportBitmap(const boost::filesystem::path & path) const override;
bool isTransparent(const Point & coords) const override;
Point dimensions() const override;
void setAlpha(uint8_t value) override;
void setBlitMode(EImageBlitMode mode) override;
void draw(SDL_Surface * where, const Point & pos, const Rect * src) const override;
void setOverlayColor(const ColorRGBA & color) override;
2024-07-21 23:11:02 +02:00
void playerColored(PlayerColor player) override;
void shiftPalette(uint32_t firstColorID, uint32_t colorsToMove, uint32_t distanceToMove) override;
void adjustPalette(const ColorFilter & shifter, uint32_t colorsToSkipMask) override;
std::shared_ptr<const ISharedImage> getSharedImage() const override;
2024-07-21 23:11:02 +02:00
};