forked from fedetft/mxgui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resource_image.h
116 lines (98 loc) · 4.12 KB
/
resource_image.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/***************************************************************************
* Copyright (C) 2011 by Terraneo Federico *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* As a special exception, if other files instantiate templates or use *
* macros or inline functions from this file, or you compile this file *
* and link it with other works to produce a work based on this file, *
* this file does not by itself cause the resulting work to be covered *
* by the GNU General Public License. However the source code for this *
* file must still be made available in accordance with the GNU General *
* Public License. This exception does not invalidate any other reasons *
* why a work based on this file might be covered by the GNU General *
* Public License. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, see <http://www.gnu.org/licenses/> *
***************************************************************************/
#include "image.h"
#include <config/mxgui_settings.h>
#ifndef RESOURCE_IMAGE_H
#define RESOURCE_IMAGE_H
#ifdef MXGUI_ENABLE_RESOURCEFS
namespace mxgui {
class ResourceImageImpl; //Forward declaration
/**
* \ingroup pub_iface
* This is a class for handling images stored in the ResourceFs filesystem,
* and is the primary reason why ResourceFs was designed.
*/
class ResourceImage : public ImageBase
{
public:
/**
* Default constructor
*/
ResourceImage(): pImpl(0) {}
/**
* Constructor.
* \param name name of image file inside the resource filesystem
*/
explicit ResourceImage(const char *name): pImpl(0) { this->open(name); }
/**
* Copy constructor
* \param rhs instance to copy from
*/
ResourceImage(const ResourceImage& rhs);
/**
* Operator =
* \param rhs instance to copy from
* \return reference to *this
*/
ResourceImage& operator=(const ResourceImage&);
/**
* Open a file
* \param name name of image file inside the resource filesystem
*/
void open(const char *name);
/**
* Close image file
*/
void close();
/**
* \return true if image is open
*/
bool isOpen() const { return pImpl!=0; }
/**
* Get pixels from tha image. This member function can be used to get
* up to a full horizontal line of pixels from an image.
* \param p Start point, within <0,0> and <getWidth()-1,getHeight()-1>
* \param colors pixel data is returned here. Array size must be equal to
* the length parameter
* \param length number of pixel to retrieve from the starting point.
* start.x()+length must be less or equal to getWidth()
* \return true if success. If false then it means the class does not
* represent a valid image, or a disk error occurred in case the image
* is stored on disk.
*/
virtual bool getScanLine(mxgui::Point p, mxgui::Color colors[],
unsigned short length) const;
/**
* Desctructor
*/
virtual ~ResourceImage() { close(); }
private:
ResourceImageImpl *pImpl;
};
} // namespace mxgui
#endif //MXGUI_ENABLE_RESOURCEFS
#endif //RESOURCE_IMAGE_H