/** * 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); }
/* * Convert a palette-independent value to a hardware color */ MWPIXELVAL GdFindColor(MWCOLORVAL c) { /* * Handle truecolor displays. Note that the MWF_PALINDEX * bit is ignored when running truecolor drivers. */ switch(gr_pixtype) { case MWPF_TRUECOLOR0888: case MWPF_TRUECOLOR888: /* create 24 bit 8/8/8 pixel (0x00RRGGBB) from RGB colorval*/ /*RGB2PIXEL888(REDVALUE(c), GREENVALUE(c), BLUEVALUE(c))*/ return COLOR2PIXEL888(c); case MWPF_TRUECOLOR565: /* create 16 bit 5/6/5 format pixel from RGB colorval*/ /*RGB2PIXEL565(REDVALUE(c), GREENVALUE(c), BLUEVALUE(c))*/ return COLOR2PIXEL565(c); case MWPF_TRUECOLOR555: /* create 16 bit 5/5/5 format pixel from RGB colorval*/ /*RGB2PIXEL555(REDVALUE(c), GREENVALUE(c), BLUEVALUE(c))*/ return COLOR2PIXEL555(c); case MWPF_TRUECOLOR332: /* create 8 bit 3/3/2 format pixel from RGB colorval*/ /*RGB2PIXEL332(REDVALUE(c), GREENVALUE(c), BLUEVALUE(c))*/ return COLOR2PIXEL332(c); } /* case MWPF_PALETTE: must be running 1, 2, 4 or 8 bit palette*/ /* * Check if color is a palette index. Note that the index * isn't error checked against the system palette, for speed. */ if(c & MWF_PALINDEX) return (c & 0xff); /* search palette for closest match*/ return GdFindNearestColor(gr_palette, (int)gr_ncolors, c); }