mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-03 04:27:44 +08:00
fix warnings
This commit is contained in:
parent
e66b95c67f
commit
14f702f1d8
@ -33,7 +33,7 @@
|
|||||||
rr = pixel & 0xff;
|
rr = pixel & 0xff;
|
||||||
#define a_from_image8888(pixel) (pixel >> 24)
|
#define a_from_image8888(pixel) (pixel >> 24)
|
||||||
#endif /*WITH_BITMAP_BGRA*/
|
#endif /*WITH_BITMAP_BGRA*/
|
||||||
#define rgb_to_image8888(r, g, b) rgba_to_image8888(r, g, b, 0xff)
|
#define rgb_to_image8888(r, g, b) rgba_to_image8888(r, g, b, (uint8_t)0xff)
|
||||||
|
|
||||||
static inline uint32_t rgb565_to_8888(uint16_t pixel) {
|
static inline uint32_t rgb565_to_8888(uint16_t pixel) {
|
||||||
uint8_t r, g, b;
|
uint8_t r, g, b;
|
||||||
|
88
src/ext_widgets/color_picker/rgb_and_hsv.c
Normal file → Executable file
88
src/ext_widgets/color_picker/rgb_and_hsv.c
Normal file → Executable file
@ -36,29 +36,29 @@
|
|||||||
void convertCMYtoRGB(const float c, const float m, const float y, unsigned char* r,
|
void convertCMYtoRGB(const float c, const float m, const float y, unsigned char* r,
|
||||||
unsigned char* g, unsigned char* b) {
|
unsigned char* g, unsigned char* b) {
|
||||||
/* Perform a cheap ceiling because e.g. it returns 9.99~ which truncates to 9 */
|
/* Perform a cheap ceiling because e.g. it returns 9.99~ which truncates to 9 */
|
||||||
*r = ((1.0 - c) * 255.0) + 0.5;
|
*r = ((1.0f - c) * 255.0f) + 0.5f;
|
||||||
*g = ((1.0 - m) * 255.0) + 0.5;
|
*g = ((1.0f - m) * 255.0f) + 0.5f;
|
||||||
*b = ((1.0 - y) * 255.0) + 0.5;
|
*b = ((1.0f - y) * 255.0f) + 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void convertRGBtoCMY(const unsigned char r, const unsigned char g, const unsigned char b, float* c,
|
void convertRGBtoCMY(const unsigned char r, const unsigned char g, const unsigned char b, float* c,
|
||||||
float* m, float* y) {
|
float* m, float* y) {
|
||||||
*c = 1.0 - (r / 255.0);
|
*c = 1.0f - (r / 255.0f);
|
||||||
*m = 1.0 - (g / 255.0);
|
*m = 1.0f - (g / 255.0f);
|
||||||
*y = 1.0 - (b / 255.0);
|
*y = 1.0f - (b / 255.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convertCMYtoCMYK(float* c, float* m, float* y, float* k) {
|
void convertCMYtoCMYK(float* c, float* m, float* y, float* k) {
|
||||||
*k = MIN3(*c, *m, *y);
|
*k = MIN3(*c, *m, *y);
|
||||||
*c = ((int)*k == 1) ? 1 : (*c - *k) / (1.0 - *k);
|
*c = ((int)*k == 1) ? 1 : (*c - *k) / (1.0f - *k);
|
||||||
*m = ((int)*k == 1) ? 1 : (*m - *k) / (1.0 - *k);
|
*m = ((int)*k == 1) ? 1 : (*m - *k) / (1.0f - *k);
|
||||||
*y = ((int)*k == 1) ? 1 : (*y - *k) / (1.0 - *k);
|
*y = ((int)*k == 1) ? 1 : (*y - *k) / (1.0f - *k);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convertCMYKtoCMY(float* c, float* m, float* y, const float k) {
|
void convertCMYKtoCMY(float* c, float* m, float* y, const float k) {
|
||||||
*c = MIN(1.0, (*c * (1.0 - k)) + k);
|
*c = MIN(1.0f, (*c * (1.0f - k)) + k);
|
||||||
*m = MIN(1.0, (*m * (1.0 - k)) + k);
|
*m = MIN(1.0f, (*m * (1.0f - k)) + k);
|
||||||
*y = MIN(1.0, (*y * (1.0 - k)) + k);
|
*y = MIN(1.0f, (*y * (1.0f - k)) + k);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convertCMYKtoRGB(const float c, const float m, const float y, const float k, unsigned char* r,
|
void convertCMYKtoRGB(const float c, const float m, const float y, const float k, unsigned char* r,
|
||||||
@ -81,45 +81,45 @@ void convertRGBtoCMYK(const unsigned char r, const unsigned char g, const unsign
|
|||||||
void convertHSVtoRGB_(const float h, const float s, const float v, unsigned char* r,
|
void convertHSVtoRGB_(const float h, const float s, const float v, unsigned char* r,
|
||||||
unsigned char* g, unsigned char* b) {
|
unsigned char* g, unsigned char* b) {
|
||||||
/* Convert hue back to 0-6 space, floor */
|
/* Convert hue back to 0-6 space, floor */
|
||||||
const float hex = h / 60.0;
|
const float hex = h / 60.0f;
|
||||||
const unsigned char primary = (int)hex;
|
const unsigned char primary = (int)hex;
|
||||||
const float secondary = hex - primary;
|
const float secondary = hex - primary;
|
||||||
|
|
||||||
/* a, b, c */
|
/* a, b, c */
|
||||||
const float x = (1.0 - s) * v;
|
const float x = (1.0f - s) * v;
|
||||||
const float y = (1.0 - (s * secondary)) * v;
|
const float y = (1.0f - (s * secondary)) * v;
|
||||||
const float z = (1.0 - (s * (1.0 - secondary))) * v;
|
const float z = (1.0f - (s * (1.0f - secondary))) * v;
|
||||||
|
|
||||||
if (primary == 0) {
|
if (primary == 0) {
|
||||||
/* 0: R = v, G = c, B = a */
|
/* 0: R = v, G = c, B = a */
|
||||||
*r = (v * 255.0) + 0.5;
|
*r = (v * 255.0f) + 0.5f;
|
||||||
*g = (z * 255.0) + 0.5;
|
*g = (z * 255.0f) + 0.5f;
|
||||||
*b = (x * 255.0) + 0.5;
|
*b = (x * 255.0f) + 0.5f;
|
||||||
} else if (primary == 1) {
|
} else if (primary == 1) {
|
||||||
/* 1: R = b, G = v, B = a */
|
/* 1: R = b, G = v, B = a */
|
||||||
*r = (y * 255.0) + 0.5;
|
*r = (y * 255.0f) + 0.5f;
|
||||||
*g = (v * 255.0) + 0.5;
|
*g = (v * 255.0f) + 0.5f;
|
||||||
*b = (x * 255.0) + 0.5;
|
*b = (x * 255.0f) + 0.5f;
|
||||||
} else if (primary == 2) {
|
} else if (primary == 2) {
|
||||||
/* 2: R = a, G = v, B = c */
|
/* 2: R = a, G = v, B = c */
|
||||||
*r = (x * 255.0) + 0.5;
|
*r = (x * 255.0f) + 0.5f;
|
||||||
*g = (v * 255.0) + 0.5;
|
*g = (v * 255.0f) + 0.5f;
|
||||||
*b = (z * 255.0) + 0.5;
|
*b = (z * 255.0f) + 0.5f;
|
||||||
} else if (primary == 3) {
|
} else if (primary == 3) {
|
||||||
/* 3: R = a, G = b, B = v */
|
/* 3: R = a, G = b, B = v */
|
||||||
*r = (x * 255.0) + 0.5;
|
*r = (x * 255.0f) + 0.5f;
|
||||||
*g = (y * 255.0) + 0.5;
|
*g = (y * 255.0f) + 0.5f;
|
||||||
*b = (v * 255.0) + 0.5;
|
*b = (v * 255.0f) + 0.5f;
|
||||||
} else if (primary == 4) {
|
} else if (primary == 4) {
|
||||||
/* 4: R = c, G = a, B = v */
|
/* 4: R = c, G = a, B = v */
|
||||||
*r = (z * 255.0) + 0.5;
|
*r = (z * 255.0f) + 0.5f;
|
||||||
*g = (x * 255.0) + 0.5;
|
*g = (x * 255.0f) + 0.5f;
|
||||||
*b = (v * 255.0) + 0.5;
|
*b = (v * 255.0f) + 0.5f;
|
||||||
} else if (primary == 5) {
|
} else if (primary == 5) {
|
||||||
/* 5: R = v, G = a, B = b */
|
/* 5: R = v, G = a, B = b */
|
||||||
*r = (v * 255.0) + 0.5;
|
*r = (v * 255.0f) + 0.5f;
|
||||||
*g = (x * 255.0) + 0.5;
|
*g = (x * 255.0f) + 0.5f;
|
||||||
*b = (y * 255.0) + 0.5;
|
*b = (y * 255.0f) + 0.5f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,42 +138,42 @@ void convertHSVtoRGB(const float h, const float s, const float v, unsigned char*
|
|||||||
void convertRGBtoHSV(const unsigned char r, const unsigned char g, const unsigned char b, float* h,
|
void convertRGBtoHSV(const unsigned char r, const unsigned char g, const unsigned char b, float* h,
|
||||||
float* s, float* v) {
|
float* s, float* v) {
|
||||||
const unsigned char max = MAX3(r, g, b);
|
const unsigned char max = MAX3(r, g, b);
|
||||||
const float max2 = max / 255.0;
|
const float max2 = max / 255.0f;
|
||||||
const unsigned char min = MIN3(r, g, b);
|
const unsigned char min = MIN3(r, g, b);
|
||||||
const float min2 = min / 255.0;
|
const float min2 = min / 255.0f;
|
||||||
|
|
||||||
*s = (max2 < 0.0001) ? 0 : (max2 - min2) / max2;
|
*s = (max2 < 0.0001f) ? 0 : (max2 - min2) / max2;
|
||||||
*v = max2;
|
*v = max2;
|
||||||
|
|
||||||
/* Saturation is 0 */
|
/* Saturation is 0 */
|
||||||
if ((*s * 100.0) < 0.1) {
|
if ((*s * 100.0f) < 0.1f) {
|
||||||
/* Hue is undefined, monochrome */
|
/* Hue is undefined, monochrome */
|
||||||
*h = 0;
|
*h = 0;
|
||||||
return;
|
return;
|
||||||
} else if (r == max) {
|
} else if (r == max) {
|
||||||
if (g == min) {
|
if (g == min) {
|
||||||
/* H = 5 + B' */
|
/* H = 5 + B' */
|
||||||
*h = 5 + ((max2 - (b / 255.0)) / (max2 - min2));
|
*h = 5 + ((max2 - (b / 255.0f)) / (max2 - min2));
|
||||||
} else {
|
} else {
|
||||||
/* H = 1 - G' */
|
/* H = 1 - G' */
|
||||||
*h = 1 - ((max2 - (g / 255.0)) / (max2 - min2));
|
*h = 1 - ((max2 - (g / 255.0f)) / (max2 - min2));
|
||||||
}
|
}
|
||||||
} else if (g == max) {
|
} else if (g == max) {
|
||||||
if (b == min) {
|
if (b == min) {
|
||||||
/* H = R' + 1 */
|
/* H = R' + 1 */
|
||||||
*h = ((max2 - (r / 255.0)) / (max2 - min2)) + 1;
|
*h = ((max2 - (r / 255.0f)) / (max2 - min2)) + 1;
|
||||||
} else {
|
} else {
|
||||||
/* H = 3 - B' */
|
/* H = 3 - B' */
|
||||||
*h = 3 - ((max2 - (b / 255.0)) / (max2 - min2));
|
*h = 3 - ((max2 - (b / 255.0f)) / (max2 - min2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* This is actually a problem with the original paper, I've fixed it here, should email them... */
|
/* This is actually a problem with the original paper, I've fixed it here, should email them... */
|
||||||
else if (b == max && r == min) {
|
else if (b == max && r == min) {
|
||||||
/* H = 3 + G' */
|
/* H = 3 + G' */
|
||||||
*h = 3 + ((max2 - (g / 255.0)) / (max2 - min2));
|
*h = 3 + ((max2 - (g / 255.0f)) / (max2 - min2));
|
||||||
} else {
|
} else {
|
||||||
/* H = 5 - R' */
|
/* H = 5 - R' */
|
||||||
*h = 5 - ((max2 - (r / 255.0)) / (max2 - min2));
|
*h = 5 - ((max2 - (r / 255.0f)) / (max2 - min2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hue is then converted to degrees by multiplying by 60 */
|
/* Hue is then converted to degrees by multiplying by 60 */
|
||||||
|
Loading…
Reference in New Issue
Block a user