Some bad distributions (Debian) apparently are not good enough to have a Pillow version from this decade packaged. Therefore, we need to do it the painful way of prefixing our symbols and refactoring everything to use them. A new header file called "utils.h" has been added for this purpose, and it is included in "overviewer.h". The following macros have been prefixed with "OV_": - MIN - MAX - CLAMP - BLEND - MULDIV255 Additionally, the C extension version was bumped to 56 because 55 was reverted back to 54.
18 lines
565 B
C
18 lines
565 B
C
#ifndef __OV_UTILS_H_INCLUDED__
|
|
#define __OV_UTILS_H_INCLUDED__
|
|
|
|
/* generally useful MAX / MIN macros */
|
|
#define OV_MAX(a, b) ((a) > (b) ? (a) : (b))
|
|
#define OV_MIN(a, b) ((a) < (b) ? (a) : (b))
|
|
#define OV_CLAMP(x, a, b) (OV_MIN(OV_MAX(x, a), b))
|
|
|
|
/* like (a * b + 127) / 255), but much faster on most platforms
|
|
from PIL's _imaging.c */
|
|
#define OV_MULDIV255(a, b, tmp)\
|
|
(tmp = (a) * (b) + 128, ((((tmp) >> 8) + (tmp)) >> 8))
|
|
|
|
#define OV_BLEND(mask, in1, in2, tmp1, tmp2)\
|
|
(OV_MULDIV255(in1, 255 - mask, tmp1) + OV_MULDIV255(in2, mask, tmp2))
|
|
|
|
#endif
|