示例#1
0
UINT32 cgfx_FindColor(CoreGfxBase *CoreGfxBase, struct CRastPort *rp, UINT32 c)
{
	PixMap *psd = rp->crp_PixMap;
//DPrintF("psd->PixType: %x\n", psd->pixtype);
	switch(psd->pixtype)
	{
		case PF_TRUECOLOR8888:
			return COLOR2PIXEL8888(c);
		case PF_TRUECOLORABGR:
			return COLOR2PIXELABGR(c);
		case PF_TRUECOLOR888:
			return COLOR2PIXEL888(c);
		case PF_TRUECOLOR565:
			return COLOR2PIXEL565(c);
		case PF_TRUECOLOR555:
			return COLOR2PIXEL555(c);
		case PF_TRUECOLOR1555:
			return COLOR2PIXEL1555(c);
		case PF_TRUECOLOR332:
			return COLOR2PIXEL332(c);
		case PF_TRUECOLOR233:
			return COLOR2PIXEL233(c);
	}
	//if (psd->ncolors == 2 && scrdev.pixtype != PF_PALETTE) return c & 1;
	return FindNearestColor(rp, (int)psd->ncolors, c);
}
示例#2
0
/**
 * Convert a palette-independent value to a hardware color
 *
 * @param psd Screen device
 * @param c 24-bit RGB color.
 * @return Hardware-specific color.
 */
MWPIXELVAL
GdFindColor(PSD psd, MWCOLORVAL c)
{
	/*
	 * Handle truecolor displays.
	 */
	switch(psd->pixtype) {
	case MWPF_TRUECOLOR8888:
		/* create 32 bit ARGB pixel (0xAARRGGBB) from ABGR colorval (0xAABBGGRR)*/
		/*RGB2PIXEL8888(REDVALUE(c), GREENVALUE(c), BLUEVALUE(c))*/
		return COLOR2PIXEL8888(c);

	case MWPF_TRUECOLORABGR:
		/* create 32 bit ABGR pixel (0xAABBGGRR) from ABGR colorval (0xAABBGGRR)*/
		/*RGB2PIXELABGR(REDVALUE(c), GREENVALUE(c), BLUEVALUE(c))*/
		return COLOR2PIXELABGR(c);

	case MWPF_TRUECOLOR888:
		/* create 24 bit 0RGB pixel (0x00RRGGBB) from ABGR colorval (0xAABBGGRR)*/
		/*RGB2PIXEL888(REDVALUE(c), GREENVALUE(c), BLUEVALUE(c))*/
		return COLOR2PIXEL888(c);

	case MWPF_TRUECOLOR565:
		/* create 16 bit RGB5/6/5 format pixel from ABGR colorval (0xAABBGGRR)*/
		/*RGB2PIXEL565(REDVALUE(c), GREENVALUE(c), BLUEVALUE(c))*/
		return COLOR2PIXEL565(c);

	case MWPF_TRUECOLOR555:
		/* create 16 bit RGB5/5/5 format pixel from ABGR colorval (0xAABBGGRR)*/
		/*RGB2PIXEL555(REDVALUE(c), GREENVALUE(c), BLUEVALUE(c))*/
		return COLOR2PIXEL555(c);

	case MWPF_TRUECOLOR1555:
		/* create 16 bit RGB5/5/5 format pixel from ABGR colorval (0xAABBGGRR)*/
		/*RGB2PIXEL1555(REDVALUE(c), GREENVALUE(c), BLUEVALUE(c))*/
		return COLOR2PIXEL1555(c);

	case MWPF_TRUECOLOR332:
		/* create 8 bit RGB3/3/2 format pixel from ABGR colorval (0xAABBGGRR)*/
		/*RGB2PIXEL332(REDVALUE(c), GREENVALUE(c), BLUEVALUE(c))*/
		return COLOR2PIXEL332(c);
	case MWPF_TRUECOLOR233:
		/* create 8 bit BGR2/3/3 format pixel from ABGR colorval (0xAABBGGRR)*/
		/*RGB2PIXEL332(REDVALUE(c), GREENVALUE(c), BLUEVALUE(c))*/
		return COLOR2PIXEL233(c);
        }

	/* case MWPF_PALETTE: must be running 1, 2, 4 or 8 bit palette*/

	/* handle 1bpp pixmaps, not running in palette mode*/
	if (psd->ncolors == 2 && scrdev.pixtype != MWPF_PALETTE)
		return c & 1;

	/* search palette for closest match*/
	return GdFindNearestColor(gr_palette, (int)psd->ncolors, c);
}