blob: 51e2da31715462b06039b99b89569cb664ace326 [file] [log] [blame]
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +00001/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19// -=- DIBSectionBuffer.h
20
21// A DIBSectionBuffer acts much like a standard PixelBuffer, but is associated
22// with a particular window on-screen and can be drawn into that window if
23// required, using the standard Win32 drawing operations.
24
25#ifndef __RFB_WIN32_DIB_SECTION_BUFFER_H__
26#define __RFB_WIN32_DIB_SECTION_BUFFER_H__
27
28#define WIN32_LEAN_AND_MEAN
29#include <windows.h>
30
31#include <rfb/PixelBuffer.h>
32#include <rfb/Region.h>
33#include <rfb/ColourMap.h>
34#include <rfb/Exception.h>
35
36namespace rfb {
37
38 namespace win32 {
39
40 //
41 // -=- DIBSectionBuffer
42 //
43
44 class DIBSectionBuffer : public FullFramePixelBuffer, ColourMap {
45 public:
46 DIBSectionBuffer(HWND window);
47 DIBSectionBuffer(HDC device);
48 virtual ~DIBSectionBuffer();
49
50 virtual void setPF(const PixelFormat &pf);
51 virtual void setSize(int w, int h);
52
53 virtual int getStride() const {return stride;}
54
55 virtual ColourMap* getColourMap() const {return (ColourMap*)this;}
56
57 // - ColourMap interface
58 virtual void lookup(int index, int* r, int *g, int* b) {
59 *r = palette[index].r;
60 *g = palette[index].g;
61 *b = palette[index].b;
62 }
63
64 // Custom colourmap interface
65 void setColour(int index, int r, int g, int b) {
66 palette[index].r = r;
67 palette[index].g = g;
68 palette[index].b = b;
69 }
70 void refreshPalette();
71
72 // *** virtual void copyRect(const Rect &dest, const Point &move_by_delta);
73 public:
74 HBITMAP bitmap;
75 protected:
76 void recreateBuffer();
77 Colour palette[256];
78 int stride;
79 HWND window;
80 HDC device;
81 };
82
83 };
84
85};
86
87#endif // __RFB_WIN32_DIB_SECTION_BUFFER_H__