summaryrefslogtreecommitdiff
path: root/common/get_first_pixel.c
blob: c1d837d8df4b95d0ccef869113c9267379c21407 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "pixmapstr.h"
#include "pixmaputil.h"

CARD32 get_first_pixel(DrawablePtr pDraw)
{
	union { CARD32 c32; CARD16 c16; CARD8 c8; char c; } pixel;

	pDraw->pScreen->GetImage(pDraw, 0, 0, 1, 1, ZPixmap, ~0, &pixel.c);

	switch (pDraw->bitsPerPixel) {
	case 32:
		return pixel.c32;
	case 16:
		return pixel.c16;
	case 8:
	case 4:
	case 1:
		return pixel.c8;
	default:
		assert(0);
	}
}