blob: ad1a310ceb6a198ac27afafb7e8b4bf389c5facf [file] [log] [blame]
Constantin Kaplinsky729598c2006-05-25 05:12:25 +00001/* Copyright (C) 2002-2005 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#include <windows.h>
29#include <rfb/PixelBuffer.h>
30#include <rfb/Region.h>
31#include <rfb/ColourMap.h>
32#include <rfb/Exception.h>
33
34namespace rfb {
35
36 namespace win32 {
37
38 //
39 // -=- DIBSectionBuffer
40 //
41
42 class DIBSectionBuffer : public FullFramePixelBuffer, ColourMap {
43 public:
44 DIBSectionBuffer(HWND window);
45 DIBSectionBuffer(HDC device);
46 virtual ~DIBSectionBuffer();
47
48 virtual void setPF(const PixelFormat &pf);
49 virtual void setSize(int w, int h);
50
51 virtual int getStride() const {return stride;}
52
53 virtual ColourMap* getColourMap() const {return (ColourMap*)this;}
54
55 // - ColourMap interface
56 virtual void lookup(int index, int* r, int *g, int* b) {
57 *r = palette[index].r;
58 *g = palette[index].g;
59 *b = palette[index].b;
60 }
61
62 // Custom colourmap interface
63 void setColour(int index, int r, int g, int b) {
64 palette[index].r = r;
65 palette[index].g = g;
66 palette[index].b = b;
67 }
68 void refreshPalette();
69
70 // *** virtual void copyRect(const Rect &dest, const Point &move_by_delta);
71 public:
72 HBITMAP bitmap;
73 protected:
74 void recreateBuffer();
75 Colour palette[256];
76 int stride;
77 HWND window;
78 HDC device;
79 };
80
81 };
82
83};
84
85#endif // __RFB_WIN32_DIB_SECTION_BUFFER_H__