446 |
andreas |
1 |
/*
|
|
|
2 |
* Copyright (C) 2023 by Andreas Theofilu <andreas@theosys.at>
|
|
|
3 |
*
|
|
|
4 |
* This program is free software; you can redistribute it and/or modify
|
|
|
5 |
* it under the terms of the GNU General Public License as published by
|
|
|
6 |
* the Free Software Foundation; either version 3 of the License, or
|
|
|
7 |
* (at your option) any later version.
|
|
|
8 |
*
|
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
* GNU General Public License for more details.
|
|
|
13 |
*
|
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
|
15 |
* along with this program; if not, write to the Free Software Foundation,
|
|
|
16 |
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
17 |
*/
|
|
|
18 |
|
|
|
19 |
#ifndef __TBITMAP_H__
|
|
|
20 |
#define __TBITMAP_H__
|
|
|
21 |
|
|
|
22 |
#include <cstring>
|
|
|
23 |
|
|
|
24 |
class TBitmap
|
|
|
25 |
{
|
|
|
26 |
public:
|
|
|
27 |
TBitmap();
|
|
|
28 |
TBitmap(const TBitmap& bm);
|
|
|
29 |
TBitmap(const unsigned char *data, size_t size);
|
|
|
30 |
TBitmap(const unsigned char *data, int width, int height, int pixsize=4);
|
|
|
31 |
~TBitmap();
|
|
|
32 |
|
|
|
33 |
void setBitmap(const unsigned char *data, size_t size);
|
|
|
34 |
void setBitmap(const unsigned char *data, int width, int height, int pixsize=4);
|
|
|
35 |
unsigned char *getBitmap(size_t *size=nullptr);
|
|
|
36 |
size_t getSize() { return mSize; }
|
|
|
37 |
bool isValid();
|
|
|
38 |
|
|
|
39 |
int getPixline() { return mPixline; }
|
|
|
40 |
void setPixline(int pl);
|
|
|
41 |
int getWidth() { return mWidth; }
|
|
|
42 |
void setWidth(int w);
|
|
|
43 |
int getHeight() { return mHeight; }
|
|
|
44 |
void setHeight(int h);
|
|
|
45 |
|
|
|
46 |
void setSize(int w, int h);
|
|
|
47 |
void clear();
|
|
|
48 |
|
|
|
49 |
int getPixelSize() { return mPixelSize; }
|
|
|
50 |
void setPixelSize(int ps);
|
|
|
51 |
|
|
|
52 |
TBitmap& operator=(const TBitmap& bm)
|
|
|
53 |
{
|
|
|
54 |
this->clear();
|
|
|
55 |
|
|
|
56 |
if (bm.mSize > 0)
|
|
|
57 |
{
|
|
|
58 |
this->mData = new unsigned char[bm.mSize];
|
|
|
59 |
memmove(this->mData, bm.mData, bm.mSize);
|
|
|
60 |
this->mSize = bm.mSize;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
this->mPixline = bm.mPixline;
|
|
|
64 |
this->mPixelSize = bm.mPixelSize;
|
|
|
65 |
this->mWidth = bm.mWidth;
|
|
|
66 |
this->mHeight = bm.mHeight;
|
|
|
67 |
|
|
|
68 |
return *this;
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
private:
|
|
|
72 |
unsigned char *mData{nullptr};
|
|
|
73 |
size_t mSize{0};
|
|
|
74 |
int mPixline{0};
|
|
|
75 |
int mWidth{0};
|
|
|
76 |
int mHeight{0};
|
|
|
77 |
int mPixelSize{4};
|
|
|
78 |
};
|
|
|
79 |
|
|
|
80 |
#endif
|