]> source.dussan.org Git - tigervnc.git/commitdiff
Added PixelFormatList class implementation.
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Thu, 17 Mar 2005 17:37:15 +0000 (17:37 +0000)
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Thu, 17 Mar 2005 17:37:15 +0000 (17:37 +0000)
It is responsible for controlling the list of supported pixel formats.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@249 3789f03b-4d11-0410-bbf8-ca57d06f2519

rfbplayer/PixelFormatList.cxx [new file with mode: 0644]
rfbplayer/PixelFormatList.h [new file with mode: 0644]
rfbplayer/rfbplayer.dsp

diff --git a/rfbplayer/PixelFormatList.cxx b/rfbplayer/PixelFormatList.cxx
new file mode 100644 (file)
index 0000000..1cb0f69
--- /dev/null
@@ -0,0 +1,89 @@
+/* Copyright (C) 2004 TightVNC Team.  All Rights Reserved.
+ *    
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+// -=- PixelFormatList class
+
+#include <rfbplayer/PixelFormatList.h>
+
+PixelFormatList::PixelFormatList() {
+  PixelFormatListElement PFElem;
+  
+  // -=- Add the default pixel formats to list
+  // PF_BGR233
+  PFElem.setName("8-bits depth (BGR233)");
+  PFElem.setPF(&PixelFormat(8,8,0,1,7,7,3,0,3,6));
+  PFList.push_back(PFElem);
+  // PF_RGB555
+  PFElem.setName("15-bits depth (RGB555)");
+  PFElem.setPF(&PixelFormat(16,15,0,1,31,31,31,10,5,0));
+  PFList.push_back(PFElem);
+  // PF_BGR555
+  PFElem.setName("15-bits depth (BGR555)");
+  PFElem.setPF(&PixelFormat(16,15,0,1,31,31,31,0,5,10));
+  PFList.push_back(PFElem);
+  // PF_RGB565
+  PFElem.setName("16-bits depth (RGB565)");
+  PFElem.setPF(&PixelFormat(16,16,0,1,31,63,31,11,5,0));
+  PFList.push_back(PFElem);
+  // PF_BGR565
+  PFElem.setName("16-bits depth (BGR565)");
+  PFElem.setPF(&PixelFormat(16,16,0,1,31,63,31,0,5,11));
+  PFList.push_back(PFElem);
+  // PF_RGB888
+  PFElem.setName("24-bits depth (RGB888)");
+  PFElem.setPF(&PixelFormat(32,24,0,1,255,255,255,16,8,0));
+  PFList.push_back(PFElem);
+  // PF_BGR888
+  PFElem.setName("24-bits depth (BGR888)");
+  PFElem.setPF(&PixelFormat(32,24,0,1,255,255,255,0,8,16));
+  PFList.push_back(PFElem);
+}
+
+PixelFormatListElement PixelFormatList::operator[](int index) {
+  return *getIterator(index);
+}
+
+void PixelFormatList::add(char *format_name, PixelFormat PF) {
+  PixelFormatListElement PFElem;
+  PFElem.setName(format_name);
+  PFElem.setPF(&PF);
+  PFList.push_back(PFElem);
+}
+
+void PixelFormatList::insert(int index, char *format_name, PixelFormat PF) {
+  PixelFormatListElement PFElem;
+  PFElem.setName(format_name);
+  PFElem.setPF(&PF);
+  PFList.insert(getIterator(index), PFElem);
+}
+
+void PixelFormatList::remove(int index) {
+  PFList.erase(getIterator(index));
+}
+
+list <PixelFormatListElement>::iterator PixelFormatList::getIterator(int index) {
+  if ((index >= PFList.size()) || (index < 0))
+    rdr::Exception("PixelFormatList:out of range");
+
+  int i = 0;
+  list <PixelFormatListElement>::iterator iter;
+  for (iter = PFList.begin(); iter != PFList.end(); iter++) {
+    if (i++ == index) break;
+  }
+  return iter;
+}
\ No newline at end of file
diff --git a/rfbplayer/PixelFormatList.h b/rfbplayer/PixelFormatList.h
new file mode 100644 (file)
index 0000000..41ca0f2
--- /dev/null
@@ -0,0 +1,71 @@
+/* Copyright (C) 2004 TightVNC Team.  All Rights Reserved.
+ *    
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+// -=- PixelFormatList.h
+
+// Definition of the PixelFormatList class, responsible for 
+// controlling the list of supported pixel formats.
+
+#include <list>
+
+#include <rfb/Exception.h>
+#include <rfb/PixelFormat.h>
+
+// Definition indexes of the default pixel formats
+#define PF_BGR233 0
+#define PF_RGB555 1
+#define PF_BGR555 2
+#define PF_RGB565 3
+#define PF_BGR565 4
+#define PF_RGB888 5
+#define PF_BGR888 6
+#define PF_DEFAULT_COUNT 7
+
+using namespace rfb;
+using namespace std;
+
+// PixelFormatListElement class, it is 
+// an item of the PixelFormatList list.
+
+class PixelFormatListElement {
+public:
+  char format_name[256];
+  PixelFormat PF;
+  void setName(const char *name) {
+    format_name[0] = '\0';
+    strcpy(format_name, name);
+    format_name[strlen(name)] = '\0';
+  }
+  void setPF(PixelFormat *_PF) {
+    memcpy(&PF, _PF, sizeof(PixelFormat));
+  }
+};
+
+class PixelFormatList {
+public:
+  PixelFormatList();
+  PixelFormatListElement operator[](int index);
+  void add(char *format_name, PixelFormat PF);
+  void insert(int index, char *format_name, PixelFormat PF);
+  void remove(int index);
+  int count() { return PFList.size(); }
+
+protected:
+  list <PixelFormatListElement>::iterator getIterator(int index);
+  list <PixelFormatListElement> PFList;
+};
\ No newline at end of file
index 76a40cf4cfa8d1e9b2d3e73735ed142e48378151..cc6a795461316bb99be8ecd549827c71ab2bcea0 100644 (file)
@@ -108,6 +108,10 @@ SOURCE=.\FbsInputStream.cxx
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\PixelFormatList.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\PlayerOptions.cxx\r
 # End Source File\r
 # Begin Source File\r
@@ -148,6 +152,10 @@ SOURCE=.\OptionsDialog.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\PixelFormatList.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\PlayerOptions.h\r
 # End Source File\r
 # Begin Source File\r