PlayerOptions::pixelFormat changed to pixelFormatIndex.
Added new property pixelFormat to PlayerOptions class.
Added supportedPF to RfbPlayer class.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@252 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/rfbplayer/OptionsDialog.h b/rfbplayer/OptionsDialog.h
index 7cc0a52..484791a 100644
--- a/rfbplayer/OptionsDialog.h
+++ b/rfbplayer/OptionsDialog.h
@@ -40,7 +40,7 @@
     SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("8 bit depth (RGB332)"));
     SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("16 bit depth (RGB655)"));
     SendMessage(combo, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)("24 bit depth (RGB888)"));
-    SendMessage(combo, CB_SETCURSEL, options->pixelFormat, 0);
+    SendMessage(combo, CB_SETCURSEL, options->pixelFormatIndex, 0);
     if (options->askPixelFormat) {
       setItemChecked(IDC_ASK_PF, true);
       enableItem(IDC_PIXELFORMAT, false);
@@ -52,7 +52,7 @@
   }
   virtual bool onOk() {
     if (!isItemChecked(IDC_ASK_PF)) {
-      options->pixelFormat = SendMessage(combo, CB_GETCURSEL, 0, 0);
+      options->pixelFormatIndex = SendMessage(combo, CB_GETCURSEL, 0, 0);
     }
     options->askPixelFormat = isItemChecked(IDC_ASK_PF);
     options->acceptBell = isItemChecked(IDC_ACCEPT_BELL);
diff --git a/rfbplayer/PlayerOptions.cxx b/rfbplayer/PlayerOptions.cxx
index aea0efe..8a8bf36 100644
--- a/rfbplayer/PlayerOptions.cxx
+++ b/rfbplayer/PlayerOptions.cxx
@@ -28,16 +28,21 @@
 
 void PlayerOptions::readFromRegistry() {
   try {
+    PixelFormat *pPF = 0;
+    int pfSize = sizeof(PixelFormat);
     RegKey regKey;
     regKey.createKey(HKEY_CURRENT_USER, _T("Software\\TightVnc\\RfbPlayer"));
     autoPlay = regKey.getBool(_T("AutoPlay"), DEFAULT_AUTOPLAY);
-    pixelFormat = regKey.getInt(_T("PixelFormat"), DEFAULT_PF);
+    pixelFormatIndex = regKey.getInt(_T("PixelFormatIndex"), DEFAULT_PF);
+    regKey.getBinary(_T("PixelFormat"), (void**)&pPF, &pfSize, 
+      &PixelFormat(32,24,0,1,255,255,255,16,8,0), sizeof(PixelFormat));
     acceptBell = regKey.getBool(_T("AcceptBell"), DEFAULT_ACCEPT_BELL);
     acceptCutText = regKey.getBool(_T("AcceptCutText"), DEFAULT_ACCEPT_CUT_TEXT);
     autoStoreSettings = regKey.getBool(_T("AutoStoreSettings"), DEFAULT_STORE_SETTINGS);
     autoPlay = regKey.getBool(_T("AutoPlay"), DEFAULT_AUTOPLAY);
     loopPlayback = regKey.getBool(_T("LoopPlayback"), DEFAULT_LOOP_PLAYBACK);
     askPixelFormat = regKey.getBool(_T("AskPixelFormat"), DEFAULT_ASK_PF);
+    if (pPF) delete pPF;
   } catch (rdr::Exception e) {
     MessageBox(0, e.str(), e.type(), MB_OK | MB_ICONERROR);
   }
@@ -48,7 +53,8 @@
     RegKey regKey;
     regKey.createKey(HKEY_CURRENT_USER, _T("Software\\TightVnc\\RfbPlayer"));
     regKey.setBool(_T("AutoPlay"), autoPlay);
-    regKey.setInt(_T("PixelFormat"), pixelFormat);
+    regKey.setInt(_T("PixelFormatIndex"), pixelFormatIndex);
+    regKey.setBinary(_T("PixelFormat"), &pixelFormat, sizeof(PixelFormat));
     regKey.setBool(_T("AcceptBell"), acceptBell);
     regKey.setBool(_T("AcceptCutText"), acceptCutText);
     regKey.setBool(_T("AutoStoreSettings"), autoStoreSettings);
@@ -63,7 +69,8 @@
 void PlayerOptions::writeDefaults() {
   initTime = DEFAULT_INIT_TIME;
   playbackSpeed = DEFAULT_SPEED;
-  pixelFormat = PF_AUTO;
+  pixelFormatIndex = PF_AUTO;
+  pixelFormat = PixelFormat(32,24,0,1,255,255,255,16,8,0);
   frameScale = DEFAULT_FRAME_SCALE;
   autoPlay = DEFAULT_AUTOPLAY;
   fullScreen = DEFAULT_FULL_SCREEN;
@@ -75,7 +82,7 @@
 }
 
 void PlayerOptions::setPF(PixelFormat *newPF) {
-  memcpy(&PF, newPF, sizeof(PixelFormat));
+  memcpy(&pixelFormat, newPF, sizeof(PixelFormat));
 }
 
 bool PlayerOptions::setPF(int rgb_order, int rm, int gm, int bm, bool big_endian) {
diff --git a/rfbplayer/PlayerOptions.h b/rfbplayer/PlayerOptions.h
index 2a56b3f..1bca343 100644
--- a/rfbplayer/PlayerOptions.h
+++ b/rfbplayer/PlayerOptions.h
@@ -69,8 +69,8 @@
   double playbackSpeed;
   bool autoPlay;
   bool fullScreen;
-  long pixelFormat;
-  PixelFormat PF;
+  long pixelFormatIndex;
+  PixelFormat pixelFormat;
   bool acceptBell;
   bool acceptCutText;
   bool loopPlayback;
diff --git a/rfbplayer/rfbplayer.cxx b/rfbplayer/rfbplayer.cxx
index 6de2810..d2bd1d6 100644
--- a/rfbplayer/rfbplayer.cxx
+++ b/rfbplayer/rfbplayer.cxx
@@ -25,6 +25,7 @@
 #include <rfb_win32/Win32Util.h>
 #include <rfb_win32/WMShatter.h> 
 
+#include <rfbplayer/PixelFormatList.h>
 #include <rfbplayer/rfbplayer.h>
 
 using namespace rfb;
@@ -60,6 +61,7 @@
 // -=- RfbPlayer's defines
 
 #define strcasecmp _stricmp
+#define UPF_REGISTRY_PATH "Software\\TightVnc\\RfbPlayer\\UserDefinedPF"
 #define MAX_SPEED 10.00
 #define CALCULATION_ERROR MAX_SPEED / 1000
 #define MAX_POS_TRACKBAR_RANGE 50
@@ -226,6 +228,9 @@
   // Reset the full session time
   strcpy(fullSessionTime, "00m:00s");
 
+  // Load the user defined pixel formats from the registry
+  supportedPF.readUserDefinedPF(HKEY_CURRENT_USER, UPF_REGISTRY_PATH);
+
   // Create the main window
   const TCHAR* name = _T("RfbPlayer");
   int x = max(0, (GetSystemMetrics(SM_CXSCREEN) - DEFAULT_PLAYER_WIDTH) / 2);
@@ -894,7 +899,7 @@
       throw rdr::Exception("[TERMINATE]");
     }
   } else {
-    pixelFormat = options.pixelFormat;
+    pixelFormat = options.pixelFormatIndex;
   }
   switch (pixelFormat) {
   case PF_AUTO: 
@@ -1228,7 +1233,7 @@
       if ((pf < 0) || (pf > PF_MODES)) {
         return false;
       }
-      playerOptions.pixelFormat = pf;
+      playerOptions.pixelFormatIndex = pf;
       continue;
     }
 
diff --git a/rfbplayer/rfbplayer.h b/rfbplayer/rfbplayer.h
index 9357428..b5a9676 100644
--- a/rfbplayer/rfbplayer.h
+++ b/rfbplayer/rfbplayer.h
@@ -177,6 +177,7 @@
 
     // The player's parameters
     PlayerOptions options;
+    PixelFormatList supportedPF;
     long imageDataStartTime;
     long sessionTimeMs;
 };