]> git.vomp.tv Git - vompclient.git/blob - src/bitmap.h
Implement Log shutdown
[vompclient.git] / src / bitmap.h
1 /*
2     Copyright 2008 Mark Calderbank
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software Foundation, Inc.,
18     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #ifndef BITMAP_H
22 #define BITMAP_H
23
24 #include "defines.h"
25 #include <vector>
26
27 class DisplayRegion
28 {
29   public:
30     DisplayRegion();
31     u4 windowx, windowy, windoww, windowh;
32     u4 framewidth,frameheight;
33 };
34
35 class Palette
36 {
37   public:
38     Palette(u1 tBpp = 8);
39     u1 getBpp() const { return bpp; }
40     void reset() { numColours = 0; }
41     void setBpp(u1 tBpp);
42     u4 getColour(u1 index) const { return index < maxColours ? colour[index] : 0; }
43     void setColour(u1 index, u4 tColour);
44     void setYCrCbA(u1 index, u1 tY, u1 tCr, u1 tCb, u1 tA);
45     const std::vector<u4>& getColourVector() const { return colour; }
46     const std::vector<u1>& getYVector() const { return Y; }
47     const std::vector<u1>& getCrVector() const { return Cr; }
48     const std::vector<u1>& getCbVector() const { return Cb; }
49     const std::vector<u1>& getAVector() const { return A; }
50     u4 getNumColours() const { return numColours; }
51   private:
52     const static u4 MAX_DEPTH = 8;
53     std::vector<u4> colour;
54     std::vector<u1> Y;
55     std::vector<u1> Cr;
56     std::vector<u1> Cb;
57     std::vector<u1> A;
58     u1 bpp;
59     u4 maxColours, numColours;
60     void argb2yrba(u4 argb, u1& y, u1& cr, u1& cb, u1& a);
61     u4 yrba2argb(u1 y, u1 cr, u1 cb, u1 a);
62 };
63
64 class Bitmap
65 {
66   private:
67     std::vector<u1> bitmap;
68     u4 width, height;
69   public:
70     Bitmap(u4 tWidth = 0, u4 tHeight = 0, u1 tBpp = 8);
71     Palette palette;
72     u4 getWidth() const { return width; }
73     u4 getHeight() const { return height; }
74     u1 getIndex(u4 x, u4 y) const;
75     u4 getColour(u4 x, u4 y) const;
76     const std::vector<u1> & rawData() const { return bitmap; }
77     void setSize(u4 tWidth, u4 tHeight);
78     bool setIndex(u4 x, u4 y, u1 index);
79     void setAllIndices(u1 index);
80 }; 
81
82 #endif