예제 #1
0
파일: wingdi.c 프로젝트: EPiCS/reconos_v2
/* return RGB value at specified coordinates*/
COLORREF WINAPI
GetPixel(HDC hdc, int x, int y)
{
	HWND		hwnd;
	POINT		pt;
	MWPIXELVAL	pixel;
	MWPALENTRY	rgb;

	hwnd = MwPrepareDC(hdc);
	if(!hwnd)
		return CLR_INVALID;
	pt.x = x;
	pt.y = y;
	if(MwIsClientDC(hdc))
		ClientToScreen(hwnd, &pt);

	/* read pixel value*/
	GdReadArea(hdc->psd, pt.x, pt.y, 1, 1, &pixel);

	switch(hdc->psd->pixtype) {
	case MWPF_TRUECOLOR0888:
	case MWPF_TRUECOLOR888:
		/* create RGB colorval from 8/8/8 pixel*/
		return PIXEL888TOCOLORVAL(pixel);

	case MWPF_TRUECOLOR565:
		/* create RGB colorval from 5/6/5 pixel*/
		return PIXEL565TOCOLORVAL(pixel);

	case MWPF_TRUECOLOR555:
		/* create RGB colorval from 5/5/5 pixel*/
		return PIXEL555TOCOLORVAL(pixel);

	case MWPF_TRUECOLOR332:
		/* create RGB colorval from 3/3/2 pixel*/
		return PIXEL332TOCOLORVAL(pixel);

	case MWPF_TRUECOLOR233:
		/* create RGB colorval from 2/3/3 pixel*/
		return PIXEL233TOCOLORVAL(pixel);

	case MWPF_PALETTE:
		if(GdGetPalette(hdc->psd, pixel, 1, &rgb))
			return RGB(rgb.r, rgb.g, rgb.b);
	}
	return CLR_INVALID;
}
예제 #2
0
/**
 * Convert a color from a driver-dependent PIXELVAL to a COLORVAL.
 *
 * @param psd Screen device.
 * @param pixel Hardware-specific color.
 * @return 24-bit RGB color.
 */
MWCOLORVAL
GdGetColorRGB(PSD psd, MWPIXELVAL pixel)
{
	switch (psd->pixtype) {
	case MWPF_TRUECOLOR8888:
		return PIXEL8888TOCOLORVAL(pixel);

	case MWPF_TRUECOLORABGR:
		return PIXELABGRTOCOLORVAL(pixel);

	case MWPF_TRUECOLOR888:
		return PIXEL888TOCOLORVAL(pixel);

	case MWPF_TRUECOLOR565:
		return PIXEL565TOCOLORVAL(pixel);

	case MWPF_TRUECOLOR555:
		return PIXEL555TOCOLORVAL(pixel);

	case MWPF_TRUECOLOR1555:
 	        return PIXEL1555TOCOLORVAL(pixel);

	case MWPF_TRUECOLOR332:
		return PIXEL332TOCOLORVAL(pixel);

	case MWPF_TRUECOLOR233:
		return PIXEL233TOCOLORVAL(pixel);

	case MWPF_PALETTE:
		return GETPALENTRY(gr_palette, pixel);

	default:
		assert(FALSE);
		return 0;
	}
}