Ejemplo n.º 1
0
void vgainten(Sint4 inten)
{
#ifdef WIN32
  /*GdiFlush();*/
#endif
  cur_intensity=inten;
  if (g_bWindowed)
  {
#ifdef WIN32  
    SetDIBColorTable(back_dc,0,16, windowed_palette[cur_palette*2 + cur_intensity]);
#else
    WinGSetDIBColorTable(back_dc,0,16, windowed_palette[cur_palette*2 + cur_intensity]);
#endif    
    if (use_async_screen_updates)
      InvalidateRect(hWnd, NULL, FALSE);
    else
      blit_to_window();
  }
#ifdef DIRECTX
  else
  {
    IDirectDrawSurface4_SetPalette(g_pDDSPrimary, fullscreen_palette[cur_palette*2 + cur_intensity]);
    SetDIBColorTable(back_dc,0,16, windowed_palette[cur_palette*2 + cur_intensity]);
  }
#endif
};
Ejemplo n.º 2
0
int curses_start_color(void)
{
    //TODO: this should be reviewed in the future.

    colorpairs = new pairs[100];
    windowsPalette = new RGBQUAD[16];

    //Load the console colors from colors.json
    std::ifstream colorfile(FILENAMES["colors"].c_str(), std::ifstream::in | std::ifstream::binary);
    try{
        JsonIn jsin(colorfile);
        char ch;
        // Manually load the colordef object because the json handler isn't loaded yet.
        jsin.eat_whitespace();
        ch = jsin.peek();
        if( ch == '[' ) {
            jsin.start_array();
            // find type and dispatch each object until array close
            while (!jsin.end_array()) {
                jsin.eat_whitespace();
                char ch = jsin.peek();
                if (ch != '{') {
                    jsin.error( string_format( "expected array of objects but found '%c', not '{'", ch ) );
                }
                JsonObject jo = jsin.get_object();
                load_colors(jo);
                jo.finish();
            }
        } else {
            // not an array?
            jsin.error( string_format( "expected object or array, but found '%c'", ch ) );
        }
    } catch( const JsonError &err ){
        throw std::runtime_error( FILENAMES["colors"] + ": " + err.what() );
    }

    if(consolecolors.empty())return SetDIBColorTable(backbuffer, 0, 16, windowsPalette);
    windowsPalette[0]  = BGR(ccolor("BLACK"));
    windowsPalette[1]  = BGR(ccolor("RED"));
    windowsPalette[2]  = BGR(ccolor("GREEN"));
    windowsPalette[3]  = BGR(ccolor("BROWN"));
    windowsPalette[4]  = BGR(ccolor("BLUE"));
    windowsPalette[5]  = BGR(ccolor("MAGENTA"));
    windowsPalette[6]  = BGR(ccolor("CYAN"));
    windowsPalette[7]  = BGR(ccolor("GRAY"));
    windowsPalette[8]  = BGR(ccolor("DGRAY"));
    windowsPalette[9]  = BGR(ccolor("LRED"));
    windowsPalette[10] = BGR(ccolor("LGREEN"));
    windowsPalette[11] = BGR(ccolor("YELLOW"));
    windowsPalette[12] = BGR(ccolor("LBLUE"));
    windowsPalette[13] = BGR(ccolor("LMAGENTA"));
    windowsPalette[14] = BGR(ccolor("LCYAN"));
    windowsPalette[15] = BGR(ccolor("WHITE"));
    return SetDIBColorTable(backbuffer, 0, 16, windowsPalette);
}
Ejemplo n.º 3
0
void CImgBitsDIB::SetTransIndex(LONG lIndex)
{
    Assert(_iBitCount <= 8);
    Assert(lIndex>=-1 && lIndex<(1<<_iBitCount));

    _iTrans = lIndex;

    if(lIndex >= 0)
    {
        if(_hbmImg)
        {
            HDC hdcMem;
            HBITMAP hbmSav;

            hdcMem = GetMemoryDC();
            if(!hdcMem)
            {
                return;
            }

            hbmSav = (HBITMAP)SelectObject(hdcMem, _hbmImg);
            SetDIBColorTable(hdcMem, lIndex, 1, &g_rgbWhite);
            SelectObject(hdcMem, hbmSav);
            ReleaseMemoryDC(hdcMem);
        }
        else if(_pbmih)
        {
            ((RGBQUAD*)(_pbmih+1))[_iTrans] = g_rgbWhite;
        }
    }
}
Ejemplo n.º 4
0
int BMPanvas::CopyPallete(BMPanvas *src)
{
    int ret=0;
    ret+=GetDIBColorTable(src->hdc,0,256,INFO.bmiColors);
    ret+=SetDIBColorTable(hdc,0,256,INFO.bmiColors);
    CheckColorType();
    return ret;
}
Ejemplo n.º 5
0
void SetPalette(CSBitmap* pBitmap, int StartColor, int NumColors, RGBQUAD* pColors)
{
	assert(HasBitmap(pBitmap));
	assert(GetChannels(pBitmap) == 1);
	assert(StartColor >= 0);
	assert(StartColor + NumColors <= 256);
	SetDIBColorTable(GetDrawSurface(pBitmap), StartColor, NumColors, pColors);
}
Ejemplo n.º 6
0
bool CBitmap::setPalette(int start_color, int num_colors, RGBQUAD *colors)
{	
	// Returns 0 on failure, number of entries set on success
	// For more on this function check it out in MSDN
	if(SetDIBColorTable(bmp_hdc, start_color, num_colors, colors))
		return true;
	else
		return false;
}
Ejemplo n.º 7
0
// Copy from DIB's color table to DIB section's color table
UINT KDIBSection::SetColorTable(void)
{
	int width, height;

	if ( (GetDepth()>8) || ! Prepare(width, height) ) // create memory DC
		return 0;

	return SetDIBColorTable(m_hMemDC, 0, m_nClrUsed, m_pRGBQUAD);
}
Ejemplo n.º 8
0
// Applies palette to screen/window
void gr_palette_apply(ubyte *palette) {
	EnterCriticalSection(&palettecs);
	for (int i = 0; i < 256; ++i) {
		bmi->bmiColors[i].rgbRed = palette[i * 3 + 0] * 4;
		bmi->bmiColors[i].rgbGreen = palette[i * 3 + 1] * 4;
		bmi->bmiColors[i].rgbBlue = palette[i * 3 + 2] * 4;
	}
	SetDIBColorTable(hDibDC, 0, 256, bmi->bmiColors);
	LeaveCriticalSection(&palettecs);
}
Ejemplo n.º 9
0
static Bool
winInstallColormapShadowGDI (ColormapPtr pColormap)
{
  ScreenPtr		pScreen = pColormap->pScreen;
  winScreenPriv(pScreen);
  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
  winCmapPriv(pColormap);

  /*
   * Tell Windows to install the new colormap
   */
  if (SelectPalette (pScreenPriv->hdcScreen,
		     pCmapPriv->hPalette,
		     FALSE) == NULL)
    {
      ErrorF ("winInstallColormapShadowGDI - SelectPalette () failed\n");
      return FALSE;
    }
      
  /* Realize the palette */
  if (GDI_ERROR == RealizePalette (pScreenPriv->hdcScreen))
    {
      ErrorF ("winInstallColormapShadowGDI - RealizePalette () failed\n");
      return FALSE;
    }

  /* Set the DIB color table */
  if (SetDIBColorTable (pScreenPriv->hdcShadow,
			0,
			WIN_NUM_PALETTE_ENTRIES,
			pCmapPriv->rgbColors) == 0)
    {
      ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
      return FALSE;
    }

  /* Redraw the whole window, to take account for the new colors */
  BitBlt (pScreenPriv->hdcScreen,
	  0, 0,
	  pScreenInfo->dwWidth, pScreenInfo->dwHeight,
	  pScreenPriv->hdcShadow,
	  0, 0,
	  SRCCOPY);

  /* Save a pointer to the newly installed colormap */
  pScreenPriv->pcmapInstalled = pColormap;

#ifdef XWIN_MULTIWINDOW
  /* Redraw all windows */
  if (pScreenInfo->fMultiWindow)
    EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
#endif

  return TRUE;
}
Ejemplo n.º 10
0
void ieImageDIB_CLUTorL::OnCLUTChanged()
{
	if (!pCLUT || (hBmp == NULL)) return;

	if (hPal != NULL) {
		DeleteObject(hPal);
		hPal = NULL;
	}

	SetDIBColorTable(hMemDC, 0, 256, (RGBQUAD *) pCLUT);	// An RGBQUAD is identical with BGRA
}
Ejemplo n.º 11
0
static Bool
winStoreColorsShadowGDI (ColormapPtr pColormap,
			 int ndef,
			 xColorItem *pdefs)
{
  ScreenPtr		pScreen = pColormap->pScreen;
  winScreenPriv(pScreen);
  winCmapPriv(pColormap);
  ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
  
  /* Put the X colormap entries into the Windows logical palette */
  if (SetPaletteEntries (pCmapPriv->hPalette,
			 pdefs[0].pixel,
			 ndef,
			 pCmapPriv->peColors + pdefs[0].pixel) == 0)
    {
      ErrorF ("winStoreColorsShadowGDI - SetPaletteEntries () failed\n");
      return FALSE;
    }

  /* Don't install the Windows palette if the colormap is not installed */
  if (pColormap != curpmap)
    {
      return TRUE;
    }

  /* Try to install the newly modified colormap */
  if (!winInstallColormapShadowGDI (pColormap))
    {
      ErrorF ("winInstallColormapShadowGDI - winInstallColormapShadowGDI "
	      "failed\n");
      return FALSE;
    }

#if 0
  /* Tell Windows that the palette has changed */
  RealizePalette (pScreenPriv->hdcScreen);
  
  /* Set the DIB color table */
  if (SetDIBColorTable (pScreenPriv->hdcShadow,
			pdefs[0].pixel,
			ndef,
			pCmapPriv->rgbColors + pdefs[0].pixel) == 0)
    {
      ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
      return FALSE;
    }

  /* Save a pointer to the newly installed colormap */
  pScreenPriv->pcmapInstalled = pColormap;
#endif

  return TRUE;
}
Ejemplo n.º 12
0
int BMPanvas::CreateGrayPallete()
{
    int ret=0;
    RGBQUAD col;
    for(int i=0; i<256; i++) {
        col.rgbBlue=col.rgbGreen=col.rgbRed=(BYTE)i;
        INFO.bmiColors[i]=col;
    }
    ret=SetDIBColorTable(hdc,0,256,INFO.bmiColors);
    CheckColorType();
    return ret;
}
Ejemplo n.º 13
0
bool CBitmap::setPalette(int startColor, int numColors, RGBQUAD *colors)
{	
	// If the CBitmap is not an 8-bit bitmap, CAN NOT set palette
	if(mChannels != 1)
		return false;

	// Returns 0 on failure, number of entries set on success
	if(SetDIBColorTable(mHDC, startColor, numColors, colors))
		return true;
	else
		return false;
}
Ejemplo n.º 14
0
void CDECL wined3d_palette_apply_to_dc(const struct wined3d_palette *palette, HDC dc)
{
    if (SetDIBColorTable(dc, 0, 256, palette->colors) != 256)
#ifdef __REACTOS__
    {
        static int warn_once;
        if (!warn_once++)
            ERR("Failed to set DIB color table. (Only printing once)\n");
    }
#else
        ERR("Failed to set DIB color table.\n");
#endif
}
Ejemplo n.º 15
0
static void UpdatePalette(HDC dc, uint start, uint count)
{
	RGBQUAD rgb[256];
	uint i;

	for (i = 0; i != count; i++) {
		rgb[i].rgbRed   = _local_palette.palette[start + i].r;
		rgb[i].rgbGreen = _local_palette.palette[start + i].g;
		rgb[i].rgbBlue  = _local_palette.palette[start + i].b;
		rgb[i].rgbReserved = 0;
	}

	SetDIBColorTable(dc, start, count, rgb);
}
Ejemplo n.º 16
0
int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
{
	RGBQUAD *pal;
	int i;
#ifndef _WIN32_WCE
	HDC hdc, mdc;
#else
	HDC hdc;
#endif

	/* Update the display palette */
	hdc = GetDC(SDL_Window);
	if ( screen_pal ) {
		PALETTEENTRY *entries;

		entries = (PALETTEENTRY *)alloca(ncolors*sizeof(PALETTEENTRY));
		for ( i=0; i<ncolors; ++i ) {
			entries[i].peRed   = colors[i].r;
			entries[i].peGreen = colors[i].g;
			entries[i].peBlue  = colors[i].b;
			entries[i].peFlags = PC_NOCOLLAPSE;
		}
		SetPaletteEntries(screen_pal, firstcolor, ncolors, entries);
		SelectPalette(hdc, screen_pal, FALSE);
		RealizePalette(hdc);
	}

	/* Copy palette colors into DIB palette */
	pal = (RGBQUAD *)alloca(ncolors*sizeof(RGBQUAD));
	for ( i=0; i<ncolors; ++i ) {
		pal[i].rgbRed = colors[i].r;
		pal[i].rgbGreen = colors[i].g;
		pal[i].rgbBlue = colors[i].b;
		pal[i].rgbReserved = 0;
	}

	/* Set the DIB palette and update the display */
#ifndef _WIN32_WCE
	mdc = CreateCompatibleDC(hdc);
	SelectObject(mdc, screen_bmp);
	SetDIBColorTable(mdc, firstcolor, ncolors, pal);
	BitBlt(hdc, 0, 0, this->screen->w, this->screen->h,
	       mdc, 0, 0, SRCCOPY);
	DeleteDC(mdc);
#endif
	ReleaseDC(SDL_Window, hdc);
	return(1);
}
Ejemplo n.º 17
0
/*! Restore original palette and draw bitmap
// \param RECT &rc : 
// \param HDC hdcDST : 
// \param HDC hdcSRC : 
*/
BOOL CAxJpgCard::DrawOriginalColors(RECT &rc, HDC hdcDST, HDC hdcSRC)
{
    RGBQUAD pColors[256];
    
    for (int i = 0; i < 256; i++)
    {
        pColors[i].rgbBlue = m_pColors[i].rgbBlue;
        pColors[i].rgbGreen = m_pColors[i].rgbGreen;
        pColors[i].rgbRed = m_pColors[i].rgbRed;
    }
    
    
    int a = SetDIBColorTable(hdcSRC, 0, 256, pColors );
    StretchBlt(hdcDST, rc.left, rc.top, (rc.right - rc.left) , (rc.bottom - rc.top), hdcSRC, 0,0, e_BmW, e_BmH, SRCCOPY );
    
    return TRUE;
    
}
Ejemplo n.º 18
0
Bool
qtRealizeInstalledPaletteShadow (ScreenPtr pScreen)
{
#if 0	/* ### NOT YET */
	winScreenPriv(pScreen);
	winPrivCmapPtr	pCmapPriv = NULL;

#if QTDEBUG
	ErrorF ("qtRealizeInstalledPaletteShadow\n");
#endif

	/* Don't do anything if there is not a colormap */
	if (pScreenPriv->pcmapInstalled == NULL)
	{
#if QTDEBUG
		ErrorF ("qtRealizeInstalledPaletteShadow - No colormap "
			"installed\n");
#endif
		return TRUE;
	}

	pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
  
	/* Realize our palette for the screen */
	if (RealizePalette (pScreenPriv->hdcScreen) == _ERROR)
	{
		ErrorF ("qtRealizeInstalledPaletteShadow - RealizePalette () "
			"failed\n");
		return FALSE;
	}
  
	/* Set the DIB color table */
	if (SetDIBColorTable (pScreenPriv->hdcShadow,
			      0,
			      WIN_NUM_PALETTE_ENTRIES,
			      pCmapPriv->rgbColors) == 0)
	{
		ErrorF ("qtRealizeInstalledPaletteShadow - SetDIBColorTable () "
			"failed\n");
		return FALSE;
	}
#endif  
	return TRUE;
}
Ejemplo n.º 19
0
static Bool
winRealizeInstalledPaletteShadowGDI (ScreenPtr pScreen)
{
  winScreenPriv(pScreen);
  winPrivCmapPtr	pCmapPriv = NULL;

#if CYGDEBUG
  winDebug ("winRealizeInstalledPaletteShadowGDI\n");
#endif

  /* Don't do anything if there is not a colormap */
  if (pScreenPriv->pcmapInstalled == NULL)
    {
#if CYGDEBUG
      winDebug ("winRealizeInstalledPaletteShadowGDI - No colormap "
	      "installed\n");
#endif
      return TRUE;
    }

  pCmapPriv = winGetCmapPriv (pScreenPriv->pcmapInstalled);
  
  /* Realize our palette for the screen */
  if (RealizePalette (pScreenPriv->hdcScreen) == GDI_ERROR)
    {
      ErrorF ("winRealizeInstalledPaletteShadowGDI - RealizePalette () "
	      "failed\n");
      return FALSE;
    }
  
  /* Set the DIB color table */
  if (SetDIBColorTable (pScreenPriv->hdcShadow,
			0,
			WIN_NUM_PALETTE_ENTRIES,
			pCmapPriv->rgbColors) == 0)
    {
      ErrorF ("winRealizeInstalledPaletteShadowGDI - SetDIBColorTable () "
	      "failed\n");
      return FALSE;
    }
  
  return TRUE;
}
Ejemplo n.º 20
0
BOOL __stdcall _SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETTEENTRY *pPalEntries, int a4)
{
  for ( unsigned int i = firstentry; i < firstentry + numentries; ++i )
  {
    wmodebmp.bmiColors[i].rgbRed   = pPalEntries[i].peRed;
    wmodebmp.bmiColors[i].rgbGreen = pPalEntries[i].peGreen;
    wmodebmp.bmiColors[i].rgbBlue  = pPalEntries[i].peBlue;
  }
  if ( !wmode || !ghMainWnd )
  {
    if ( _SDrawUpdatePaletteOld )
      return _SDrawUpdatePaletteOld(firstentry, numentries, pPalEntries, a4);
    return SDrawUpdatePalette(firstentry, numentries, pPalEntries, a4);
  }

  if ( !IsIconic(ghMainWnd) )
    SetDIBColorTable(hdcMem, firstentry, numentries, wmodebmp.bmiColors);
  return TRUE;
}
Ejemplo n.º 21
0
int InitBitmapAndColorTable()
{
    int i;
    BITMAPINFO bmi = {0};
    RGBQUAD colorTable[256];

    g_memDC = CreateCompatibleDC(GetDC(NULL));
    if (!g_memDC)
    {
        return -1;
    }

    bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    bmi.bmiHeader.biWidth = SCREEN_WIDTH;
    bmi.bmiHeader.biHeight = -SCREEN_HEIGHT;
    bmi.bmiHeader.biPlanes = 1;
    bmi.bmiHeader.biBitCount = 8;
    bmi.bmiHeader.biCompression = BI_RGB;

    g_bitmap = CreateDIBSection(g_memDC, &bmi, DIB_PAL_COLORS, &g_bitmapBits, NULL, 0);
    if (!g_bitmap)
    {
        return -3;
    }

    SelectObject(g_memDC, g_bitmap);

    // Initialize Color Table
    for (i = 0; i < 256; ++i)
    {
        colorTable[i].rgbBlue = g_palette[i].B;
        colorTable[i].rgbGreen = g_palette[i].G;
        colorTable[i].rgbRed = g_palette[i].R;
        colorTable[i].rgbReserved = 0;
    }

    if (SetDIBColorTable(g_memDC, 0, 256, colorTable) != 256)
    {
        return -2;
    }

    return 0;
}
Ejemplo n.º 22
0
/*! Change the color of the bitmap to blend to dark
*/
BOOL CAxJpgCard::AnimateToBlack(RECT &rc, HDC hdcDST, HDC hdcSRC)
{
    RGBQUAD pColors[256];
    
    for (int i = 0; i < 256; i++)
    {
        pColors[i].rgbBlue = m_pColors[i].rgbBlue;
        pColors[i].rgbGreen = m_pColors[i].rgbGreen;
        pColors[i].rgbRed = m_pColors[i].rgbRed;
    }
    
    
    BYTE byReduct = 5;
    for (int j = 0; j < 50; j++)
    {
        StretchBlt(hdcDST, rc.left, rc.top, (rc.right - rc.left) , (rc.bottom - rc.top), hdcSRC, 0,0, e_BmW, e_BmH, SRCCOPY );
        
        for (int i = 0; i < 256; i++)
        {
            (pColors[i].rgbBlue > byReduct) ? pColors[i].rgbBlue -= byReduct : 0;
            (pColors[i].rgbGreen > byReduct) ? pColors[i].rgbGreen -= byReduct : 0;
            (pColors[i].rgbRed > byReduct) ? pColors[i].rgbRed -= byReduct : 0;
            
        }
        int a = SetDIBColorTable(hdcSRC, 0, 256, pColors );
        
        Sleep(5);
    }
    
    /*
    char szMsg[1024];
    
      for (i = 0; i < 256; i++)
      {
      ::sprintf(szMsg, _T("pColors[%d].Blue = %d, Green = %d, Red = %d \n"), i, pColors[i].rgbBlue, pColors[i].rgbGreen, pColors[i].rgbRed );
      ::OutputDebugString(szMsg);
      }
    */
    
    return TRUE;
    
}
Ejemplo n.º 23
0
ULONG FASTCALL WG32SetDIBColorTable(PVDMFRAME pFrame)
{
    ULONG              ul = 0;
    RGBQUAD *          prgb;

    register PSETDIBCOLORTABLE16 parg16;

    GETARGPTR(pFrame, sizeof(SETDIBCOLORTABLE16), parg16);
    GETMISCPTR(parg16->f4,prgb);

    ul = (ULONG)SetDIBColorTable(HDC32(parg16->f1),
                                 parg16->f2,
                                 parg16->f3,
                                 prgb);

    WOW32APIWARN(ul, "SetDIBColorTable");

    FREEMISCPTR(prgb);
    FREEARGPTR(parg16);

    return(ul);
}
Ejemplo n.º 24
0
int curses_start_color(void)
{
    colorpairs = new pairs[100];
    windowsPalette = new RGBQUAD[16];
    windowsPalette[0]  = BGR(0,0,0);         // Black
    windowsPalette[1]  = BGR(0, 0, 255);     // Red
    windowsPalette[2]  = BGR(0,110,0);       // Green
    windowsPalette[3]  = BGR(23,51,92);      // Brown???
    windowsPalette[4]  = BGR(200, 0, 0);     // Blue
    windowsPalette[5]  = BGR(98, 58, 139);   // Purple
    windowsPalette[6]  = BGR(180, 150, 0);   // Cyan
    windowsPalette[7]  = BGR(150, 150, 150); // Gray
    windowsPalette[8]  = BGR(99, 99, 99);    // Dark Gray
    windowsPalette[9]  = BGR(150, 150, 255); // Light Red/Salmon?
    windowsPalette[10] = BGR(0, 255, 0);     // Bright Green
    windowsPalette[11] = BGR(0, 255, 255);   // Yellow
    windowsPalette[12] = BGR(255, 100, 100); // Light Blue
    windowsPalette[13] = BGR(240, 0, 255);   // Pink
    windowsPalette[14] = BGR(255, 240, 0);   // Light Cyan?
    windowsPalette[15] = BGR(255, 255, 255); //White
    return SetDIBColorTable(backbuffer, 0, 16, windowsPalette);
}
Ejemplo n.º 25
0
int start_color(void)
{
 colorpairs=new pairs[50];
 windowsPalette=new RGBQUAD[16]; //Colors in the struct are BGR!! not RGB!!
 windowsPalette[0]= BGR(0,0,0); // Black
 windowsPalette[1]= BGR(0, 0, 255); // Red
 windowsPalette[2]= BGR(0,100,0); // Green
 windowsPalette[3]= BGR(23,51,92); // Brown???
 windowsPalette[4]= BGR(150, 0, 0); // Blue
 windowsPalette[5]= BGR(98, 58, 139); // Purple
 windowsPalette[6]= BGR(180, 150, 0); // Cyan
 windowsPalette[7]= BGR(196, 196, 196);// Gray
 windowsPalette[8]= BGR(77, 77, 77);// Dark Gray
 windowsPalette[9]= BGR(150, 150, 255); // Light Red/Salmon?
 windowsPalette[10]= BGR(0, 255, 0); // Bright Green
 windowsPalette[11]= BGR(0, 255, 255); // Yellow
 windowsPalette[12]= BGR(255, 100, 100); // Light Blue
 windowsPalette[13]= BGR(240, 0, 255); // Pink
 windowsPalette[14]= BGR(255, 240, 0); // Light Cyan?
 windowsPalette[15]= BGR(255, 255, 255);
 return SetDIBColorTable(backbuffer, 0, 16, windowsPalette);
};
Ejemplo n.º 26
0
int start_color(void)
{
    colorpairs=new pairs[50];
    windowsPalette=new RGBQUAD[16];     //Colors in the struct are BGR!! not RGB!!
    windowsPalette[0]= BGR(0,0,0);
    windowsPalette[1]= BGR(0, 0, 196);
    windowsPalette[2]= BGR(0,196,0);
    windowsPalette[3]= BGR(30,180,196);
    windowsPalette[4]= BGR(196, 0, 0);
    windowsPalette[5]= BGR(180, 0, 196);
    windowsPalette[6]= BGR(200, 170, 0);
    windowsPalette[7]= BGR(196, 196, 196);
    windowsPalette[8]= BGR(96, 96, 96);
    windowsPalette[9]= BGR(64, 64, 255);
    windowsPalette[10]= BGR(0, 240, 0);
    windowsPalette[11]= BGR(0, 255, 255);
    windowsPalette[12]= BGR(255, 20, 20);
    windowsPalette[13]= BGR(240, 0, 255);
    windowsPalette[14]= BGR(255, 240, 0);
    windowsPalette[15]= BGR(255, 255, 255);
    return SetDIBColorTable(backbuffer, 0, 16, windowsPalette);
};
Ejemplo n.º 27
0
static void gdi_surface_realize_palette(IWineD3DSurfaceImpl *surface)
{
    struct wined3d_palette *palette = surface->palette;

    TRACE("surface %p.\n", surface);

    if (!palette) return;

    if (surface->flags & SFLAG_DIBSECTION)
    {
        RGBQUAD col[256];
        unsigned int i;

        TRACE("Updating the DC's palette.\n");

        for (i = 0; i < 256; ++i)
        {
            col[i].rgbRed   = palette->palents[i].peRed;
            col[i].rgbGreen = palette->palents[i].peGreen;
            col[i].rgbBlue  = palette->palents[i].peBlue;
            col[i].rgbReserved = 0;
        }
        SetDIBColorTable(surface->hDC, 0, 256, col);
    }

    /* Update the image because of the palette change. Some games like e.g.
     * Red Alert call SetEntries a lot to implement fading. */
    /* Tell the swapchain to update the screen. */
    if (surface->container.type == WINED3D_CONTAINER_SWAPCHAIN)
    {
        IWineD3DSwapChainImpl *swapchain = surface->container.u.swapchain;
        if (surface == swapchain->front_buffer)
        {
            x11_copy_to_screen(swapchain, NULL);
        }
    }
}
Ejemplo n.º 28
0
void CDECL wined3d_palette_apply_to_dc(const struct wined3d_palette *palette, HDC dc)
{
    if (SetDIBColorTable(dc, 0, 256, palette->colors) != 256)
        ERR("Failed to set DIB color table.\n");
}
Ejemplo n.º 29
0
void SetWMode(int width, int height, bool state)
{
#ifndef SHADOW_BROODWAR
  // Compatibility for Xen W-Mode
  if ( ghMainWnd && !(GetWindowLong(ghMainWnd, GWL_STYLE) & WS_SYSMENU) )
    return;

  if ( !isCorrectVersion )
    return;

  if ( state )
  {
    wmode = true;
    if ( !ghMainWnd )
      return;

    // Call the DirectDraw destructor
    DDrawDestroy();
    InitializeWModeBitmap(BW::BWDATA::GameScreenBuffer.width(), BW::BWDATA::GameScreenBuffer.height());

    // Hack to enable drawing in Broodwar
    BW::BWDATA::PrimarySurface = (LPDIRECTDRAWSURFACE)1;

    const int shift = gdwProcNum > 1 ? 32 : 0;
    POINT pos = { windowRect.left + shift, windowRect.top + shift };
    // Change the window settings
    SetWindowLong(ghMainWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
    SetWindowPos(ghMainWnd, HWND_NOTOPMOST, pos.x, pos.y, width, height, SWP_SHOWWINDOW);
    ShowWindow(ghMainWnd, SW_RESTORE);

    SIZE border;
    GetBorderSize(ghMainWnd, &border);
    int w = width + border.cx;
    int h = height + border.cy;

    int cx = GetSystemMetrics(SM_CXFULLSCREEN);
    int cy = GetSystemMetrics(SM_CYFULLSCREEN);
    while ( pos.x < 0 )
      pos.x = 0;
    while ( pos.y < 0 )
      pos.y = 0;
    if ( pos.y + h >= cy )
    {
      if (gdwProcNum > 1)
        pos.y -= cy - h;
      else
        pos.y = cy - h;
    }
    if ( pos.x + w >= cx )
    {
      if (gdwProcNum > 1)
        pos.x -= cx - w;
      else
        pos.x = cx - w;
    }
    MoveWindow(ghMainWnd, pos.x, pos.y, w, h, TRUE);
    SetCursor(NULL);
    SetCursorShowState(false);

    SetDIBColorTable(hdcMem, 0, 256, wmodebmp.bmiColors);
    WriteConfig("window", "windowed", "ON");
  }
  else
  {
    wmode = false;
    BW::BWDATA::PrimarySurface = NULL;
    if ( hdcMem )
      DeleteDC(hdcMem);
    hdcMem = NULL;

    if (ghMainWnd)
    {
      SetWindowLong(ghMainWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE | WS_SYSMENU);
      SetWindowPos(ghMainWnd, HWND_TOPMOST, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW);
      SetCursor(NULL);
      SetCursorShowState(false);
      SetFocus(ghMainWnd);
    }
    DDrawDestroy();
    DDrawInitialize(width, height);
    WriteConfig("window", "windowed", "OFF");
  }
#endif
}
Ejemplo n.º 30
0
static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    CvWindow* window = icvWindowByHWND(hwnd);
    if( !window )
        // This window is not mentioned in HighGUI storage
        // Actually, this should be error except for the case of calls to CreateWindow
        return DefWindowProc(hwnd, uMsg, wParam, lParam);

    // Process the message
    switch(uMsg)
    {
    case WM_WINDOWPOSCHANGING:
        {
            LPWINDOWPOS pos = (LPWINDOWPOS)lParam;
            RECT rect = icvCalcWindowRect(window);
            pos->x = rect.left;
            pos->y = rect.top;
            pos->cx = rect.right - rect.left + 1;
            pos->cy = rect.bottom - rect.top + 1;
        }
        break;

    case WM_LBUTTONDOWN:
    case WM_RBUTTONDOWN:
    case WM_MBUTTONDOWN:
    case WM_LBUTTONDBLCLK:
    case WM_RBUTTONDBLCLK:
    case WM_MBUTTONDBLCLK:
    case WM_LBUTTONUP:
    case WM_RBUTTONUP:
    case WM_MBUTTONUP:
    case WM_MOUSEMOVE:
        if( window->on_mouse )
        {
            POINT pt;
            RECT rect;
            SIZE size = {0,0};

            int flags = (wParam & MK_LBUTTON ? CV_EVENT_FLAG_LBUTTON : 0)|
                        (wParam & MK_RBUTTON ? CV_EVENT_FLAG_RBUTTON : 0)|
                        (wParam & MK_MBUTTON ? CV_EVENT_FLAG_MBUTTON : 0)|
                        (wParam & MK_CONTROL ? CV_EVENT_FLAG_CTRLKEY : 0)|
                        (wParam & MK_SHIFT ? CV_EVENT_FLAG_SHIFTKEY : 0)|
                        (GetKeyState(VK_MENU) < 0 ? CV_EVENT_FLAG_ALTKEY : 0);
            int event = uMsg == WM_LBUTTONDOWN ? CV_EVENT_LBUTTONDOWN :
                        uMsg == WM_RBUTTONDOWN ? CV_EVENT_RBUTTONDOWN :
                        uMsg == WM_MBUTTONDOWN ? CV_EVENT_MBUTTONDOWN :
                        uMsg == WM_LBUTTONUP ? CV_EVENT_LBUTTONUP :
                        uMsg == WM_RBUTTONUP ? CV_EVENT_RBUTTONUP :
                        uMsg == WM_MBUTTONUP ? CV_EVENT_MBUTTONUP :
                        uMsg == WM_LBUTTONDBLCLK ? CV_EVENT_LBUTTONDBLCLK :
                        uMsg == WM_RBUTTONDBLCLK ? CV_EVENT_RBUTTONDBLCLK :
                        uMsg == WM_MBUTTONDBLCLK ? CV_EVENT_MBUTTONDBLCLK :
                                                   CV_EVENT_MOUSEMOVE;
            if( uMsg == WM_LBUTTONDOWN || uMsg == WM_RBUTTONDOWN || uMsg == WM_MBUTTONDOWN )
                SetCapture( hwnd );
            if( uMsg == WM_LBUTTONUP || uMsg == WM_RBUTTONUP || uMsg == WM_MBUTTONUP )
                ReleaseCapture();

            pt.x = LOWORD( lParam );
            pt.y = HIWORD( lParam );

            GetClientRect( window->hwnd, &rect );
            icvGetBitmapData( window, &size, 0, 0 );

            window->on_mouse( event, pt.x*size.cx/MAX(rect.right - rect.left,1),
                                     pt.y*size.cy/MAX(rect.bottom - rect.top,1), flags,
                                     window->on_mouse_param );
        }
        break;

    case WM_PAINT:
        if(window->image != 0)
        {
            int nchannels = 3;
            SIZE size = {0,0};
            PAINTSTRUCT paint;
            HDC hdc;
            RGBQUAD table[256];

            // Determine the bitmap's dimensions
            icvGetBitmapData( window, &size, &nchannels, 0 );

            hdc = BeginPaint(hwnd, &paint);
            SetStretchBltMode(hdc, COLORONCOLOR);

            if( nchannels == 1 )
            {
                int i;
                for(i = 0; i < 256; i++)
                {
                    table[i].rgbBlue = (unsigned char)i;
                    table[i].rgbGreen = (unsigned char)i;
                    table[i].rgbRed = (unsigned char)i;
                }
                SetDIBColorTable(window->dc, 0, 255, table);
            }

            if(window->flags & CV_WINDOW_AUTOSIZE)
            {
                BitBlt( hdc, 0, 0, size.cx, size.cy, window->dc, 0, 0, SRCCOPY );
            }
            else
            {
                RECT rect;
                GetClientRect(window->hwnd, &rect);
                StretchBlt( hdc, 0, 0, rect.right - rect.left, rect.bottom - rect.top,
                            window->dc, 0, 0, size.cx, size.cy, SRCCOPY );
            }
            //DeleteDC(hdc);
            EndPaint(hwnd, &paint);
        }
        else
        {
            return DefWindowProc(hwnd, uMsg, wParam, lParam);
        }
        return 0;

    case WM_ERASEBKGND:
        if(window->image)
            return 0;
        break;

    case WM_DESTROY:

        icvRemoveWindow(window);
        // Do nothing!!!
        //PostQuitMessage(0);
        break;

    case WM_SETCURSOR:
        SetCursor((HCURSOR)icvGetClassLongPtr(hwnd, CV_HCURSOR));
        return 0;

    case WM_KEYDOWN:
        window->last_key = (int)wParam;
        return 0;
    }

    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}