Example #1
0
//--------- Start of function Vga::load_pal ----------//
//
// Load the palette from a file and set it to the front buf.
//
BOOL Vga::load_pal(char* fileName) {
    char palBuf[256][3];
    File palFile;

    palFile.file_open(fileName);
    palFile.file_seek(8);                           // bypass the header info
    palFile.file_read(palBuf, 256*3);
    palFile.file_close();

    //--- Create a Direct Draw Palette and associate it with the front buffer ---//

    if( dd_pal == NULL ) {
	for(int i=0; i<256; i++) {
	    pal_entry_buf[i].peRed   = palBuf[i][0];
	    pal_entry_buf[i].peGreen = palBuf[i][1];
	    pal_entry_buf[i].peBlue  = palBuf[i][2];
	}

	HRESULT rc = dd_obj->CreatePalette( DDPCAPS_8BIT, pal_entry_buf, &dd_pal, NULL );

	if( rc != DD_OK )
	    return FALSE;
    }

    init_color_table();
    init_gray_remap_table();

    // set global variable
    transparent_code_w = translate_color(TRANSPARENT_CODE);

    return TRUE;
}
Example #2
0
void
tinitcolor(void)
{
    if(_color_inited || panicking())
      return;

    if(ANSI_COLOR() || (_colors > 0 && ((_setaf && _setab) || (_setf && _setb)
/**** not sure how to do this yet
       || _scp
****/
	))){
	_color_inited = 1;
	color_tbl = init_color_table();

	if(ANSI_COLOR())
	  putpad("\033[39;49m");
	else{
	    if(_op)
	      putpad(_op);
	    if(_oc)
	      putpad(_oc);
	}
    }
}
Example #3
0
NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
{
    int result = ERR;
    int maxpairs = 0, maxcolors = 0;

    T((T_CALLED("start_color(%p)"), (void *) SP_PARM));

    if (SP_PARM == 0) {
	result = ERR;
    } else if (SP_PARM->_coloron) {
	result = OK;
    } else {
	maxpairs = MaxPairs;
	maxcolors = MaxColors;
	if (reset_color_pair(NCURSES_SP_ARG) != TRUE) {
	    set_foreground_color(NCURSES_SP_ARGx
				 default_fg(NCURSES_SP_ARG),
				 NCURSES_SP_NAME(_nc_outch));
	    set_background_color(NCURSES_SP_ARGx
				 default_bg(NCURSES_SP_ARG),
				 NCURSES_SP_NAME(_nc_outch));
	}
#if !NCURSES_EXT_COLORS
	/*
	 * Without ext-colors, we cannot represent more than 256 color pairs.
	 */
	if (maxpairs > 256)
	    maxpairs = 256;
#endif

	if (maxpairs > 0 && maxcolors > 0) {
	    SP_PARM->_pair_limit = maxpairs;

#if NCURSES_EXT_FUNCS
	    /*
	     * If using default colors, allocate extra space in table to
	     * allow for default-color as a component of a color-pair.
	     */
	    SP_PARM->_pair_limit += (1 + (2 * maxcolors));
#endif
	    SP_PARM->_pair_count = maxpairs;
	    SP_PARM->_color_count = maxcolors;
#if !USE_REENTRANT
	    COLOR_PAIRS = maxpairs;
	    COLORS = maxcolors;
#endif

	    SP_PARM->_color_pairs = TYPE_CALLOC(colorpair_t, SP_PARM->_pair_limit);
	    if (SP_PARM->_color_pairs != 0) {
		SP_PARM->_color_table = TYPE_CALLOC(color_t, maxcolors);
		if (SP_PARM->_color_table != 0) {
		    SP_PARM->_color_pairs[0] = PAIR_OF(default_fg(NCURSES_SP_ARG),
						       default_bg(NCURSES_SP_ARG));
		    init_color_table(NCURSES_SP_ARG);

		    T(("started color: COLORS = %d, COLOR_PAIRS = %d",
		       COLORS, COLOR_PAIRS));

		    SP_PARM->_coloron = 1;
		    result = OK;
		} else if (SP_PARM->_color_pairs != 0) {
		    FreeAndNull(SP_PARM->_color_pairs);
		}
	    }
	} else {
	    result = OK;
	}
    }
    returnCode(result);
}