diff options
-rw-r--r-- | chalk/colorspaces/gray_u16/kis_gray_u16_colorspace.cc | 4 | ||||
-rw-r--r-- | chalk/colorspaces/gray_u8/kis_gray_colorspace.cc | 4 | ||||
-rw-r--r-- | chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc | 4 | ||||
-rw-r--r-- | chalk/sdk/kis_integer_maths.h | 21 |
4 files changed, 27 insertions, 6 deletions
diff --git a/chalk/colorspaces/gray_u16/kis_gray_u16_colorspace.cc b/chalk/colorspaces/gray_u16/kis_gray_u16_colorspace.cc index b24c48b3..43bdf40f 100644 --- a/chalk/colorspaces/gray_u16/kis_gray_u16_colorspace.cc +++ b/chalk/colorspaces/gray_u16/kis_gray_u16_colorspace.cc @@ -404,8 +404,8 @@ void KisGrayU16ColorSpace::compositeBurn(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowS TQ_UINT16 srcColor = src[channel]; TQ_UINT16 dstColor = dst[channel]; - srcColor = kMin(((UINT16_MAX - dstColor) * (UINT16_MAX + 1u)) / (srcColor + 1u), UINT16_MAX); - srcColor = kClamp(UINT16_MAX - srcColor, 0u, UINT16_MAX); + srcColor = kMin(((UINT16_MAX - dstColor) * (UINT16_MAX + 1u)) / (srcColor + 1u), (unsigned)UINT16_MAX); + srcColor = kClamp((unsigned)UINT16_MAX - srcColor, 0u, (unsigned)UINT16_MAX); TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend); diff --git a/chalk/colorspaces/gray_u8/kis_gray_colorspace.cc b/chalk/colorspaces/gray_u8/kis_gray_colorspace.cc index 7968e311..989cc2c5 100644 --- a/chalk/colorspaces/gray_u8/kis_gray_colorspace.cc +++ b/chalk/colorspaces/gray_u8/kis_gray_colorspace.cc @@ -746,8 +746,8 @@ void KisGrayColorSpace::compositeBurn(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowStri TQ_UINT8 srcColor = src[channel]; TQ_UINT8 dstColor = dst[channel]; - srcColor = kMin(((UINT8_MAX - dstColor) * (UINT8_MAX + 1)) / (srcColor + 1), UINT8_MAX); - srcColor = kClamp(UINT8_MAX - srcColor, 0u, UINT8_MAX); + srcColor = kMin(((UINT8_MAX - dstColor) * (UINT8_MAX + 1u)) / (srcColor + 1u), (unsigned)UINT8_MAX); + srcColor = kClamp((unsigned)UINT8_MAX - srcColor, 0u, (unsigned)UINT8_MAX); TQ_UINT8 newColor = UINT8_BLEND(srcColor, dstColor, srcBlend); diff --git a/chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc b/chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc index 75aa6649..40198c91 100644 --- a/chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc +++ b/chalk/colorspaces/rgb_u16/kis_rgb_u16_colorspace.cc @@ -444,8 +444,8 @@ void KisRgbU16ColorSpace::compositeBurn(TQ_UINT8 *dstRowStart, TQ_INT32 dstRowSt TQ_UINT16 srcColor = src[channel]; TQ_UINT16 dstColor = dst[channel]; - srcColor = kMin(((UINT16_MAX - dstColor) * (UINT16_MAX + 1u)) / (srcColor + 1u), UINT16_MAX); - srcColor = kClamp(UINT16_MAX - srcColor, 0u, UINT16_MAX); + srcColor = kMin(((UINT16_MAX - dstColor) * (UINT16_MAX + 1u)) / (srcColor + 1u), (unsigned)UINT16_MAX); + srcColor = kClamp((unsigned)UINT16_MAX - srcColor, 0u, (unsigned)UINT16_MAX); TQ_UINT16 newColor = UINT16_BLEND(srcColor, dstColor, srcBlend); diff --git a/chalk/sdk/kis_integer_maths.h b/chalk/sdk/kis_integer_maths.h index c8db9aee..bd52c343 100644 --- a/chalk/sdk/kis_integer_maths.h +++ b/chalk/sdk/kis_integer_maths.h @@ -19,17 +19,38 @@ #ifndef KIS_INTEGER_MATHS_H #define KIS_INTEGER_MATHS_H +#include <config.h> +#if defined(HAVE_STDINT_H) +#include <stdint.h> +#endif + +#if !defined(UINT8_MAX) #define UINT8_MAX 255u +#endif +#if !defined(UINT8_MIN) #define UINT8_MIN 0u +#endif +#if !defined(UINT16_MAX) #define UINT16_MAX 65535u +#endif +#if !defined(UINT16_MIN) #define UINT16_MIN 0u +#endif +#if !defined(UINT32_MAX) #define UINT32_MAX (4294967295u) +#endif +#if !defined(UINT32_MIN) #define UINT32_MIN 0u +#endif +#if !defined(INT16_MAX) #define INT16_MAX 32767 +#endif +#if !defined(INT16_MIN) #define INT16_MIN -32768 +#endif /// take a and scale it up by 256*b/255 inline uint UINT8_SCALEBY(uint a, uint b) |