GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/imageset.h Lines: 7 7 100.0 %
Date: 2018-11-12 Branches: 0 0 0.0 %

Line Branch Exec Source
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-2018  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_IMAGESET_H
24
#define RESOURCES_IMAGESET_H
25
26
#include "resources/resource.h"
27
28
#include "utils/vector.h"
29
30
#include "localconsts.h"
31
32
class Image;
33
34
/**
35
 * Stores a set of subimages originating from a single image.
36
 */
37
class ImageSet notfinal : public Resource
38
{
39
    public:
40
        /**
41
         * Cuts the passed image in a grid of sub images.
42
         */
43
        ImageSet(Image *const img,
44
                 const int w,
45
                 const int h,
46
                 const int margin,
47
                 const int spacing);
48
49
        A_DELETE_COPY(ImageSet)
50
51
        /**
52
         * Destructor.
53
         */
54
        ~ImageSet() override;
55
56
        /**
57
         * Returns the width of the images in the image set.
58
         */
59
        int getWidth() const noexcept2 A_WARN_UNUSED
60
3931
        { return mWidth; }
61
62
        /**
63
         * Returns the height of the images in the image set.
64
         */
65
        int getHeight() const noexcept2 A_WARN_UNUSED
66
3931
        { return mHeight; }
67
68
        typedef STD_VECTOR<Image*>::size_type size_type;
69
70
        Image* get(const size_type i) const A_WARN_UNUSED;
71
72
        size_type size() const noexcept2 A_WARN_UNUSED
73
1
        { return mImages.size(); }
74
75
        int getOffsetX() const noexcept2 A_WARN_UNUSED
76
3931
        { return mOffsetX; }
77
78
        void setOffsetX(const int n) noexcept2
79
1293
        { mOffsetX = n; }
80
81
        int getOffsetY() const noexcept2 A_WARN_UNUSED
82
3931
        { return mOffsetY; }
83
84
        void setOffsetY(const int n) noexcept2
85
1293
        { mOffsetY = n; }
86
87
        const STD_VECTOR<Image*> &getImages() const noexcept2 A_WARN_UNUSED
88
        { return mImages; }
89
90
        int calcMemoryLocal() const override;
91
92
    private:
93
        STD_VECTOR<Image*> mImages;
94
95
        int mWidth;  /**< Width of the images in the image set. */
96
        int mHeight; /**< Height of the images in the image set. */
97
        int mOffsetX;
98
        int mOffsetY;
99
};
100
101
#endif  // RESOURCES_IMAGESET_H