FifeGUI 0.2.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#include "fifechan/image.hpp"
6
7#include <string>
8
9#include "fifechan/exception.hpp"
10#include "fifechan/imageloader.hpp"
11
12namespace fcn
13{
14
16
17 Image::Image() = default;
18
19 Image::~Image() = default;
20
22 {
23 mImageLoader = imageLoader;
24 }
25
30
31 Image* Image::load(std::string const & filename, bool convertToDisplayFormat)
32 {
33 if (mImageLoader == nullptr) {
34 throwException("Trying to load an image but no image loader is set.");
35 }
36
37 return mImageLoader->load(filename, convertToDisplayFormat);
38 }
39} // namespace fcn
Abstract interface for loading image assets.
static Image * load(std::string const &filename, bool convertToDisplayFormat=true)
Loads an image by using the class' image loader.
Definition image.cpp:31
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:21
static ImageLoader * mImageLoader
Holds the image loader to be used when loading images.
Definition image.hpp:132
static ImageLoader * getImageLoader()
Gets the image loader used for loading images.
Definition image.cpp:26