Subversion Repositories tpanel

Rev

Rev 284 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 284 Rev 289
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (C) 2022 by Andreas Theofilu <andreas@theosys.at>
2
 * Copyright (C) 2023 by Andreas Theofilu <andreas@theosys.at>
3
 *
3
 *
4
 * This program is free software; you can redistribute it and/or modify
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
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
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
7
 * (at your option) any later version.
Line 17... Line 17...
17
 */
17
 */
18
 
18
 
19
#ifndef __TBITMAP_H__
19
#ifndef __TBITMAP_H__
20
#define __TBITMAP_H__
20
#define __TBITMAP_H__
21
 
21
 
22
#include <stdlib.h>
22
#include <cstring>
23
 
23
 
24
class TBitmap
24
class TBitmap
25
{
25
{
26
    public:
26
    public:
27
        TBitmap();
27
        TBitmap();
Line 32... Line 32...
32
 
32
 
33
        void setBitmap(const unsigned char *data, size_t size);
33
        void setBitmap(const unsigned char *data, size_t size);
34
        void setBitmap(const unsigned char *data, int width, int height, int pixsize=4);
34
        void setBitmap(const unsigned char *data, int width, int height, int pixsize=4);
35
        unsigned char *getBitmap(size_t *size=nullptr);
35
        unsigned char *getBitmap(size_t *size=nullptr);
36
        size_t getSize() { return mSize; }
36
        size_t getSize() { return mSize; }
-
 
37
        bool isValid();
37
 
38
 
38
        int getPixline() { return mPixline; }
39
        int getPixline() { return mPixline; }
39
        void setPixline(int pl);
40
        void setPixline(int pl);
40
        int getWidth() { return mWidth; }
41
        int getWidth() { return mWidth; }
41
        void setWidth(int w);
42
        void setWidth(int w);
42
        int getHeight() { return mHeight; }
43
        int getHeight() { return mHeight; }
43
        void setHeight(int h);
44
        void setHeight(int h);
44
 
45
 
45
        void setSize(int w, int h);
46
        void setSize(int w, int h);
-
 
47
        void clear();
46
 
48
 
47
        int getPixelSize() { return mPixelSize; }
49
        int getPixelSize() { return mPixelSize; }
48
        void setPixelSize(int ps);
50
        void setPixelSize(int ps);
49
 
51
 
50
        TBitmap& operator=(const TBitmap& bm)
52
        TBitmap& operator=(const TBitmap& bm)
51
        {
53
        {
52
            if (this->mData)
54
            this->clear();
53
            {
-
 
54
                delete[] this->mData;
-
 
55
                this->mData = nullptr;
-
 
56
                this->mSize = 0;
-
 
57
            }
-
 
58
 
55
 
59
            if (bm.mSize > 0)
56
            if (bm.mSize > 0)
60
            {
57
            {
61
                this->mData = new unsigned char[bm.mSize];
58
                this->mData = new unsigned char[bm.mSize];
62
                memmove(this->mData, bm.mData, bm.mSize);
59
                memmove(this->mData, bm.mData, bm.mSize);