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_SUBIMAGE_H |
25 |
|
|
#define RESOURCES_SUBIMAGE_H |
26 |
|
|
|
27 |
|
|
#include "localconsts.h" |
28 |
|
|
|
29 |
|
|
#include "resources/image/image.h" |
30 |
|
|
|
31 |
|
|
/** |
32 |
|
|
* A clipped version of a larger image. |
33 |
|
|
*/ |
34 |
|
|
class SubImage final : public Image |
35 |
|
|
{ |
36 |
|
|
public: |
37 |
|
|
/** |
38 |
|
|
* Constructor. |
39 |
|
|
*/ |
40 |
|
|
#ifdef USE_SDL2 |
41 |
|
|
SubImage(Image *const parent, SDL_Texture *const image, |
42 |
|
|
const int x, const int y, const int width, const int height); |
43 |
|
|
#endif // USE_SDL2 |
44 |
|
|
|
45 |
|
|
SubImage(Image *const parent, SDL_Surface *const image, |
46 |
|
|
const int x, const int y, const int width, const int height); |
47 |
|
|
#ifdef USE_OPENGL |
48 |
|
|
SubImage(Image *const parent, const GLuint image, |
49 |
|
|
const int x, const int y, const int width, const int height, |
50 |
|
|
const int texWidth, const int textHeight); |
51 |
|
|
#endif // USE_OPENGL |
52 |
|
|
|
53 |
|
|
A_DELETE_COPY(SubImage) |
54 |
|
|
|
55 |
|
|
/** |
56 |
|
|
* Destructor. |
57 |
|
|
*/ |
58 |
|
|
~SubImage() override final; |
59 |
|
|
|
60 |
|
|
/** |
61 |
|
|
* Creates a new image with the desired clipping rectangle. |
62 |
|
|
* |
63 |
|
|
* @return <code>NULL</code> if creation failed and a valid |
64 |
|
|
* image otherwise. |
65 |
|
|
*/ |
66 |
|
|
Image *getSubImage(const int x, const int y, |
67 |
|
|
const int width, |
68 |
|
|
const int height) override final A_WARN_UNUSED; |
69 |
|
|
|
70 |
|
|
ImageTypeT getType() const noexcept2 override final |
71 |
|
|
{ return ImageType::SubImage; } |
72 |
|
|
|
73 |
|
|
int calcMemoryLocal() const override; |
74 |
|
|
|
75 |
|
|
#ifdef USE_OPENGL |
76 |
|
|
void decRef() override final; |
77 |
|
|
#endif // USE_OPENGL |
78 |
|
|
|
79 |
|
|
SDL_Rect mInternalBounds; |
80 |
|
|
|
81 |
|
|
private: |
82 |
|
|
Image *mParent; |
83 |
|
|
}; |
84 |
|
|
|
85 |
|
|
#endif // RESOURCES_SUBIMAGE_H |