ManaPlus
imagehelper.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef RESOURCES_IMAGEHELPER_H
25 #define RESOURCES_IMAGEHELPER_H
26 
27 #include "localconsts.h"
28 
30 
31 PRAGMA48(GCC diagnostic push)
32 PRAGMA48(GCC diagnostic ignored "-Wshadow")
33 #include <SDL_video.h>
34 PRAGMA48(GCC diagnostic pop)
35 
36 class Dye;
37 class Image;
38 
43 {
44  friend class CompoundSprite;
45  friend class Image;
46 
47  public:
49 
50  virtual ~ImageHelper()
51  { }
52 
61  Image *load(SDL_RWops *const rw) A_WARN_UNUSED;
62 
63  virtual Image *load(SDL_RWops *const rw, Dye const &dye) A_WARN_UNUSED;
64 
65 #ifdef __GNUC__
66  virtual Image *loadSurface(SDL_Surface *const) A_WARN_UNUSED = 0;
67 
68  virtual Image *createTextSurface(SDL_Surface *const tmpImage,
69  const int width, const int height,
70  float alpha) A_WARN_UNUSED = 0;
71 #else // __GNUC__
72 
73  virtual Image *loadSurface(SDL_Surface *const) A_WARN_UNUSED
74  { return nullptr; }
75 
76  virtual Image *createTextSurface(SDL_Surface *const tmpImage,
77  const int width, const int height,
78  const float alpha) const A_WARN_UNUSED
79  { return nullptr; }
80 #endif // __GNUC__
81 
82  virtual SDL_Surface *create32BitSurface(int width,
83  int height)
84  const A_WARN_UNUSED;
85 
86  virtual void copySurfaceToImage(const Image *const image A_UNUSED,
87  const int x A_UNUSED,
88  const int y A_UNUSED,
89  SDL_Surface *const surface A_UNUSED)
90  const
91  { }
92 
93  static SDL_Surface *convertTo32Bit(SDL_Surface *const tmpImage)
95 
96  static void dumpSurfaceFormat(const SDL_Surface *const image);
97 
98  constexpr2 static void setEnableAlpha(const bool n) noexcept2
99  { mEnableAlpha = n; }
100 
101  static SDL_Surface *loadPng(SDL_RWops *const rw);
102 
104  noexcept2
105  { mUseOpenGL = useOpenGL; }
106 
108  { return mUseOpenGL; }
109 
110  virtual void postInit()
111  { }
112 
113  protected:
115  { }
116 
117  static bool mEnableAlpha;
119 };
120 
123 #endif // RESOURCES_IMAGEHELPER_H
Definition: dye.h:41
static void dumpSurfaceFormat(const SDL_Surface *const image)
virtual Image * createTextSurface(SDL_Surface *const tmpImage, const int width, const int height, const float alpha) const
Definition: imagehelper.h:76
virtual void copySurfaceToImage(const Image *const image, const int x, const int y, SDL_Surface *const surface) const
Definition: imagehelper.h:86
static RenderType mUseOpenGL
Definition: imagehelper.h:118
virtual RenderType useOpenGL() const
Definition: imagehelper.h:107
static SDL_Surface * convertTo32Bit(SDL_Surface *const tmpImage)
virtual Image * loadSurface(SDL_Surface *const)
Definition: imagehelper.h:73
static void setEnableAlpha(const bool n)
Definition: imagehelper.h:98
virtual SDL_Surface * create32BitSurface(int width, int height) const
static void setOpenGlMode(const RenderType useOpenGL)
Definition: imagehelper.h:103
static SDL_Surface * loadPng(SDL_RWops *const rw)
static bool mEnableAlpha
Definition: imagehelper.h:117
virtual void postInit()
Definition: imagehelper.h:110
Image * load(SDL_RWops *const rw)
Definition: imagehelper.cpp:50
ImageHelper * imageHelper
Definition: imagehelper.cpp:44
ImageHelper * surfaceImageHelper
Definition: imagehelper.cpp:45
#define constexpr2
Definition: localconsts.h:49
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define notfinal
Definition: localconsts.h:261
#define A_NONNULLPOINTER
Definition: localconsts.h:266
#define noexcept2
Definition: localconsts.h:50
#define PRAGMA48(str)
Definition: localconsts.h:199
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
#define A_UNUSED
Definition: localconsts.h:160
RenderType
Definition: rendertype.h:26