backport builds
[dosdemo] / src / gfxutil.h
1 #ifndef GFXUTIL_H_
2 #define GFXUTIL_H_
3
4 #include "inttypes.h"
5
6
7 #define PACK_RGB16(r, g, b) \
8         ((((uint16_t)(r) << 8) & 0xf800) | \
9          (((uint16_t)(g) << 3) & 0x7e0) | \
10          (((uint16_t)(b) >> 3) & 0x1f))
11
12 #define UNPACK_R16(c)   (((c) >> 8) & 0xf8)
13 #define UNPACK_G16(c)   (((c) >> 3) & 0xfc)
14 #define UNPACK_B16(c)   (((c) << 3) & 0xf8)
15
16
17 #ifdef BUILD_BIGENDIAN
18
19 #define PACK_RGB32(r, g, b) \
20         ((((r) & 0xff) << 8) | (((g) & 0xff) << 16) | (((b) & 0xff) << 24) | 0xff)
21
22 #define UNPACK_R32(c)   (((c) >> 8) & 0xff)
23 #define UNPACK_G32(c)   (((c) >> 16) & 0xff)
24 #define UNPACK_B32(c)   (((c) >> 24) & 0xff)
25
26 #else   /* LITTLE_ENDIAN */
27
28 #define PACK_RGB32(r, g, b) \
29         ((((r) & 0xff) << 16) | (((g) & 0xff) << 8) | ((b) & 0xff) | 0xff000000)
30
31 #define UNPACK_R32(c)   (((c) >> 16) & 0xff)
32 #define UNPACK_G32(c)   (((c) >> 8) & 0xff)
33 #define UNPACK_B32(c)   ((c) & 0xff)
34 #endif
35
36 int clip_line(int *x0, int *y0, int *x1, int *y1, int xmin, int ymin, int xmax, int ymax);
37 void draw_line(int x0, int y0, int x1, int y1, unsigned short color);
38
39 /* scale in 24.8 fixed point */
40 void blur_horiz(uint16_t *dest, uint16_t *src, int xsz, int ysz, int radius, int scale);
41 void blur_vert(uint16_t *dest, uint16_t *src, int xsz, int ysz, int radius, int scale);
42
43 void convimg_rgb24_rgb16(uint16_t *dest, unsigned char *src, int xsz, int ysz);
44
45 void blitfb(uint16_t *dest, uint16_t *src, int width, int height, int pitch_pix);
46 void blit(uint16_t *dest, int destwidth, uint16_t *src, int xsz, int ysz, int pitch_pix);
47 void blit_key(uint16_t *dest, int destwidth, uint16_t *src, int xsz, int ysz, int pitch_pix, uint16_t key);
48
49 #endif  /* GFXUTIL_H_ */