static void rfbInitColourMapSingleTableOUTVNC (char **table, rfbPixelFormat *in, rfbPixelFormat *out) { vnclog.Print(LL_ALL, VNCLOG("rfbInitColourMapSingleTable called\n")); // ALLOCATE SPACE FOR COLOUR TABLE unsigned int nEntries = 1 << in->bitsPerPixel; // Allocate the table if (*table) free(*table); *table = (char *)malloc(nEntries * sizeof(OUT_T)); if (*table == NULL) { vnclog.Print(LL_INTERR, VNCLOG("failed to allocate translation table\n")); return; } // Obtain the system palette bool create_dc = false; HDC hDC = GetDcMirror(); if (hDC == NULL) { vnclog.Print(LL_ALL, VNCLOG("Using video Palette\n")); hDC = GetDC(NULL); } else { vnclog.Print(LL_ALL, VNCLOG("Using mirror video Palette\n")); create_dc = true; } PALETTEENTRY palette[256]; UINT entries = ::GetSystemPaletteEntries(hDC, 0, 256, palette); vnclog.Print(LL_INTINFO, VNCLOG("got %u palette entries\n"), GetLastError()); if (create_dc) DeleteDC(hDC); else ReleaseDC(NULL, hDC); // - Set the rest of the palette to something nasty but usable unsigned int i; for (i=entries; i<256; i++) { palette[i].peRed = i % 2 ? 255 : 0; palette[i].peGreen = i/2 % 2 ? 255 : 0; palette[i].peBlue = i/4 % 2 ? 255 : 0; } // COLOUR TRANSLATION // We now have the colour table intact. Map it into a translation table int r, g, b; OUT_T *t = (OUT_T *)*table; for (i = 0; i < nEntries; i++) { // Split down the RGB data r = palette[i].peRed; g = palette[i].peGreen; b = palette[i].peBlue; // Now translate it t[i] = ((((r * out->redMax + 127) / 255) << out->redShift) | (((g * out->greenMax + 127) / 255) << out->greenShift) | (((b * out->blueMax + 127) / 255) << out->blueShift)); #if (OUTVNC != 8) if (out->bigEndian != in->bigEndian) { t[i] = SwapOUTVNC(t[i]); } #endif } vnclog.Print(LL_ALL, VNCLOG("rfbInitColourMapSingleTable done\n")); }
void VIDEODRIVER::VIDEODRIVER_start(int x,int y,int w,int h) { blocked=true; oldaantal=1; mypVideoMemory=NULL; OSVER=OSVersion(); if (OSVER==OSWIN2000||OSVER==OSWIN2003||OSVER==OSWINXP) { if (Mirror_driver_attach_XP(x,y,w,h)) { if (GetDcMirror()!=NULL) { mypVideoMemory=VideoMemory_GetSharedMemory(); mypchangebuf=(PCHANGES_BUF)mypVideoMemory; myframebuffer=mypVideoMemory+sizeof(CHANGES_BUF); } else { mypVideoMemory=NULL; } } else { mypVideoMemory=NULL; } } if (OSVER==OSVISTA) { if (Mirror_driver_Vista(1,x,y,w,h)) { if (GetDcMirror()!=NULL) { mypVideoMemory=VideoMemory_GetSharedMemory(); mypchangebuf=(PCHANGES_BUF)mypVideoMemory; myframebuffer=mypVideoMemory+sizeof(CHANGES_BUF); //if (mypVideoMemory==NULL) MessageBox(NULL,"MVideo driver failed", NULL, MB_OK); } else { // MessageBox(NULL,"Video driver failed", NULL, MB_OK); //////////////////////////////////////////////////////////////////////////////// if (Mirror_driver_attach_XP(x,y,w,h)) { if (GetDcMirror()!=NULL) { mypVideoMemory=VideoMemory_GetSharedMemory(); mypchangebuf=(PCHANGES_BUF)mypVideoMemory; myframebuffer=mypVideoMemory+sizeof(CHANGES_BUF); } else { mypVideoMemory=NULL; } } else { mypVideoMemory=NULL; } //////////////////////////////////////////////////////////////////////////////// //mypVideoMemory=NULL; } } else { mypVideoMemory=NULL; } } blocked=false; }