Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_arithb.h2
-rw-r--r--source/blender/blenlib/intern/arithb.c13
2 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_arithb.h b/source/blender/blenlib/BLI_arithb.h
index f31729ac54a..fedcefcd8b8 100644
--- a/source/blender/blenlib/BLI_arithb.h
+++ b/source/blender/blenlib/BLI_arithb.h
@@ -650,6 +650,8 @@ hsv_to_rgb(
float *g, float *b
);
+void hex_to_rgb(char *hexcol, float *r, float *g, float *b);
+
void
rgb_to_hsv(
float r, float g, float b,
diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c
index 723a046b699..ad2d5c1e458 100644
--- a/source/blender/blenlib/intern/arithb.c
+++ b/source/blender/blenlib/intern/arithb.c
@@ -2520,6 +2520,19 @@ void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b)
}
}
+void hex_to_rgb(char *hexcol, float *r, float *g, float *b)
+{
+ unsigned int ri, gi, bi;
+
+ if (hexcol[0] == '#') hexcol++;
+
+ if (sscanf(hexcol, "%02x%02x%02x", &ri, &gi, &bi)) {
+ *r = ri / 255.0;
+ *g = gi / 255.0;
+ *b = bi / 255.0;
+ }
+}
+
void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv)
{
float h, s, v;