From: george82 Date: Sat, 19 Mar 2005 11:19:00 +0000 (+0000) Subject: PlayerOptions::pixelFormat changed to pixelFormatIndex. X-Git-Tag: v0.0.90~384^2~583 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0981b34ce48ff8b7aafad6accaac4521522e350e;p=tigervnc.git 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 7cc0a52f..484791ad 100644 --- a/rfbplayer/OptionsDialog.h +++ b/rfbplayer/OptionsDialog.h @@ -40,7 +40,7 @@ protected: 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 @@ protected: } 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 aea0efea..8a8bf360 100644 --- a/rfbplayer/PlayerOptions.cxx +++ b/rfbplayer/PlayerOptions.cxx @@ -28,16 +28,21 @@ PlayerOptions::PlayerOptions() { 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 @@ void PlayerOptions::writeToRegistry() { 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::writeToRegistry() { 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::writeDefaults() { } 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 2a56b3fe..1bca3438 100644 --- a/rfbplayer/PlayerOptions.h +++ b/rfbplayer/PlayerOptions.h @@ -69,8 +69,8 @@ public: 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 6de28103..d2bd1d6c 100644 --- a/rfbplayer/rfbplayer.cxx +++ b/rfbplayer/rfbplayer.cxx @@ -25,6 +25,7 @@ #include #include +#include #include using namespace rfb; @@ -60,6 +61,7 @@ char usage_msg[] = // -=- 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 @@ RfbPlayer::RfbPlayer(char *_fileName, PlayerOptions *_options) // 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 @@ void RfbPlayer::serverInit() { throw rdr::Exception("[TERMINATE]"); } } else { - pixelFormat = options.pixelFormat; + pixelFormat = options.pixelFormatIndex; } switch (pixelFormat) { case PF_AUTO: @@ -1228,7 +1233,7 @@ bool processParams(int argc, char* argv[]) { 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 9357428c..b5a96766 100644 --- a/rfbplayer/rfbplayer.h +++ b/rfbplayer/rfbplayer.h @@ -177,6 +177,7 @@ class RfbPlayer : public RfbProto { // The player's parameters PlayerOptions options; + PixelFormatList supportedPF; long imageDataStartTime; long sessionTimeMs; };