blob: 1cb0f690a709a066257e82c4b242d4ad7acb0b59 [file] [log] [blame]
george82951e7252005-03-17 17:37:15 +00001/* Copyright (C) 2004 TightVNC Team. 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// -=- PixelFormatList class
20
21#include <rfbplayer/PixelFormatList.h>
22
23PixelFormatList::PixelFormatList() {
24 PixelFormatListElement PFElem;
25
26 // -=- Add the default pixel formats to list
27 // PF_BGR233
28 PFElem.setName("8-bits depth (BGR233)");
29 PFElem.setPF(&PixelFormat(8,8,0,1,7,7,3,0,3,6));
30 PFList.push_back(PFElem);
31 // PF_RGB555
32 PFElem.setName("15-bits depth (RGB555)");
33 PFElem.setPF(&PixelFormat(16,15,0,1,31,31,31,10,5,0));
34 PFList.push_back(PFElem);
35 // PF_BGR555
36 PFElem.setName("15-bits depth (BGR555)");
37 PFElem.setPF(&PixelFormat(16,15,0,1,31,31,31,0,5,10));
38 PFList.push_back(PFElem);
39 // PF_RGB565
40 PFElem.setName("16-bits depth (RGB565)");
41 PFElem.setPF(&PixelFormat(16,16,0,1,31,63,31,11,5,0));
42 PFList.push_back(PFElem);
43 // PF_BGR565
44 PFElem.setName("16-bits depth (BGR565)");
45 PFElem.setPF(&PixelFormat(16,16,0,1,31,63,31,0,5,11));
46 PFList.push_back(PFElem);
47 // PF_RGB888
48 PFElem.setName("24-bits depth (RGB888)");
49 PFElem.setPF(&PixelFormat(32,24,0,1,255,255,255,16,8,0));
50 PFList.push_back(PFElem);
51 // PF_BGR888
52 PFElem.setName("24-bits depth (BGR888)");
53 PFElem.setPF(&PixelFormat(32,24,0,1,255,255,255,0,8,16));
54 PFList.push_back(PFElem);
55}
56
57PixelFormatListElement PixelFormatList::operator[](int index) {
58 return *getIterator(index);
59}
60
61void PixelFormatList::add(char *format_name, PixelFormat PF) {
62 PixelFormatListElement PFElem;
63 PFElem.setName(format_name);
64 PFElem.setPF(&PF);
65 PFList.push_back(PFElem);
66}
67
68void PixelFormatList::insert(int index, char *format_name, PixelFormat PF) {
69 PixelFormatListElement PFElem;
70 PFElem.setName(format_name);
71 PFElem.setPF(&PF);
72 PFList.insert(getIterator(index), PFElem);
73}
74
75void PixelFormatList::remove(int index) {
76 PFList.erase(getIterator(index));
77}
78
79list <PixelFormatListElement>::iterator PixelFormatList::getIterator(int index) {
80 if ((index >= PFList.size()) || (index < 0))
81 rdr::Exception("PixelFormatList:out of range");
82
83 int i = 0;
84 list <PixelFormatListElement>::iterator iter;
85 for (iter = PFList.begin(); iter != PFList.end(); iter++) {
86 if (i++ == index) break;
87 }
88 return iter;
89}