FifeGUI 0.3.0
A C++ GUI library designed for games.
image.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5// Corresponding header include
6#include "fifechan/image.hpp"
7
8// Standard library includes
9#include <cassert>
10#include <string>
11
12// Platform config include
13#include "fifechan/platform.hpp"
14
15// Project headers (subdirs before local)
16#include "fifechan/exception.hpp"
17#include "fifechan/imageloader.hpp"
18
19namespace fcn
20{
21
23
24 Image::Image() = default;
25
26 Image::~Image() = default;
27
29 {
30 assert("Image loader must not be null" && imageLoader != nullptr);
31 mImageLoader = imageLoader;
32 }
33
38
40 {
41 mImageLoader = nullptr;
42 }
43
44 Image* Image::load(std::string const & filename, bool convertToDisplayFormat)
45 {
46 assert("Image loader must be set before loading" && mImageLoader != nullptr);
47 assert("Filename must not be empty" && !filename.empty());
48
49 return mImageLoader->load(filename, convertToDisplayFormat);
50 }
51} // namespace fcn
Abstract interface for loading image assets.
static void resetImageLoader()
Resets the image loader used for loading images, detaching it from the Image class.
Definition image.cpp:39
static Image * load(std::string const &filename, bool convertToDisplayFormat=true)
Loads an image by using the class' image loader.
Definition image.cpp:44
virtual void convertToDisplayFormat()=0
Converts the image, if possible, to display format.
static void setImageLoader(ImageLoader *imageLoader)
Sets the ImageLoader to be used for loading images.
Definition image.cpp:28
static ImageLoader * mImageLoader
Holds the image loader to be used when loading images.
Definition image.hpp:143
static ImageLoader * getImageLoader()
Gets the image loader used for loading images.
Definition image.cpp:34
Used replacement tokens by configure_file():