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