From: george82 Date: Thu, 17 Mar 2005 17:37:15 +0000 (+0000) Subject: Added PixelFormatList class implementation. X-Git-Tag: v0.0.90~384^2~586 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=951e725b6259b7917f10c3f5aa5a2c038e611688;p=tigervnc.git Added PixelFormatList class implementation. 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 --- diff --git a/rfbplayer/PixelFormatList.cxx b/rfbplayer/PixelFormatList.cxx new file mode 100644 index 00000000..1cb0f690 --- /dev/null +++ b/rfbplayer/PixelFormatList.cxx @@ -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 + +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 ::iterator PixelFormatList::getIterator(int index) { + if ((index >= PFList.size()) || (index < 0)) + rdr::Exception("PixelFormatList:out of range"); + + int i = 0; + list ::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 index 00000000..41ca0f22 --- /dev/null +++ b/rfbplayer/PixelFormatList.h @@ -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 + +#include +#include + +// 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 ::iterator getIterator(int index); + list PFList; +}; \ No newline at end of file diff --git a/rfbplayer/rfbplayer.dsp b/rfbplayer/rfbplayer.dsp index 76a40cf4..cc6a7954 100644 --- a/rfbplayer/rfbplayer.dsp +++ b/rfbplayer/rfbplayer.dsp @@ -108,6 +108,10 @@ SOURCE=.\FbsInputStream.cxx # End Source File # Begin Source File +SOURCE=.\PixelFormatList.cxx +# End Source File +# Begin Source File + SOURCE=.\PlayerOptions.cxx # End Source File # Begin Source File @@ -148,6 +152,10 @@ SOURCE=.\OptionsDialog.h # End Source File # Begin Source File +SOURCE=.\PixelFormatList.h +# End Source File +# Begin Source File + SOURCE=.\PlayerOptions.h # End Source File # Begin Source File