]> git.vomp.tv Git - vompclient.git/blob - bitmap.h
Windows fixes
[vompclient.git] / 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     UINT windowx, windowy, windoww, windowh;
32     UINT framewidth,frameheight;
33 };
34
35 class Palette
36 {
37   public:
38     Palette(UCHAR tBpp = 8);
39     UCHAR getBpp() const { return bpp; }
40     void reset() { numColours = 0; }
41     void setBpp(UCHAR tBpp);
42     ULONG getColour(UCHAR index) const { return index < maxColours ? colour[index] : 0; }
43     void setColour(UCHAR index, ULONG tColour);
44     void setYCrCbA(UCHAR index, UCHAR tY, UCHAR tCr, UCHAR tCb, UCHAR tA);
45     const std::vector<ULONG>& getColourVector() const { return colour; }
46     const std::vector<UCHAR>& getYVector() const { return Y; }
47     const std::vector<UCHAR>& getCrVector() const { return Cr; }
48     const std::vector<UCHAR>& getCbVector() const { return Cb; }
49     const std::vector<UCHAR>& getAVector() const { return A; }
50     UINT getNumColours() const { return numColours; }
51   private:
52     const static UINT MAX_DEPTH = 8;
53     std::vector<ULONG> colour;
54     std::vector<UCHAR> Y;
55     std::vector<UCHAR> Cr;
56     std::vector<UCHAR> Cb;
57     std::vector<UCHAR> A;
58     UCHAR bpp;
59     UINT maxColours, numColours;
60     void argb2yrba(ULONG argb, UCHAR& y, UCHAR& cr, UCHAR& cb, UCHAR& a);
61     ULONG yrba2argb(UCHAR y, UCHAR cr, UCHAR cb, UCHAR a);
62 };
63
64 class Bitmap
65 {
66   private:
67     std::vector<UCHAR> bitmap;
68     UINT width, height;
69   public:
70     Bitmap(UINT tWidth = 0, UINT tHeight = 0, UCHAR tBpp = 8);
71     Palette palette;
72     UINT getWidth() const { return width; }
73     UINT getHeight() const { return height; }
74     UCHAR getIndex(UINT x, UINT y) const;
75     ULONG getColour(UINT x, UINT y) const;
76     const std::vector<UCHAR> & rawData() const { return bitmap; }
77     void setSize(UINT tWidth, UINT tHeight);
78     bool setIndex(UINT x, UINT y, UCHAR index);
79     void setAllIndices(UCHAR index);
80 }; 
81
82 #endif