Freeciv21
Develop your civilization from humble roots to a global empire
colorizer.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2022 Louis Moureaux <m_louis30@yahoo.com>
3  *
4  * SPDX-License-Identifier: GPLv3-or-later
5  */
6 
7 #pragma once
8 
9 #include <QBitmap>
10 #include <QColor>
11 #include <QPixmap>
12 
13 #include <map>
14 
15 namespace freeciv {
16 
17 class colorizer : public QObject {
18  Q_OBJECT
19 
20 public:
21  explicit colorizer(const QPixmap &base, int hue_to_replace,
22  QObject *parent = nullptr);
23  virtual ~colorizer() = default;
24 
26  QPixmap base() const { return m_base; }
27 
28  const QPixmap *pixmap(const QColor &color) const;
29 
30 private:
31  QPixmap m_base;
32  QImage m_base_image;
34  mutable std::map<QRgb, QPixmap> m_cache;
35 };
36 
37 } // namespace freeciv
colors in QPixmap
Definition: colorizer.h:17
virtual ~colorizer()=default
QPixmap base() const
Returns the base pixmap used by this colorizer.
Definition: colorizer.h:26
std::map< QRgb, QPixmap > m_cache
Definition: colorizer.h:34
const QPixmap * pixmap(const QColor &color) const
Returns a pixmap with some pixels changed to the target color.
Definition: colorizer.cpp:36
colorizer(const QPixmap &base, int hue_to_replace, QObject *parent=nullptr)
Creates a colorizer that will replace every pixel of the given hue.
Definition: colorizer.cpp:25
QImage m_base_image
Definition: colorizer.h:32
Definition: path.cpp:10