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:
authorCampbell Barton <ideasman42@gmail.com>2011-06-24 07:49:56 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-06-24 07:49:56 +0400
commit734a4aa428da5c4a3e05eddbb643c0d26df3e69d (patch)
tree032de0df22bb1e89c6ecb306762ef8558884eed1 /source/blender/blenlib
parentfc95ebbc556426b072fc41435bb76cadb16a56df (diff)
fix [#27746] Black and White Render doesn't work and/or Saves as a Blank screen
convert to grayscale when saving renders rather then only writing the red channel.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_color.h1
-rw-r--r--source/blender/blenlib/intern/math_color.c5
2 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index fe09706cb3d..a6a1238a064 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -70,6 +70,7 @@ unsigned int rgb_to_cpack(float r, float g, float b);
unsigned int hsv_to_cpack(float h, float s, float v);
float rgb_to_grayscale(float rgb[3]);
+unsigned char rgb_to_grayscale_byte(unsigned char rgb[3]);
/***************** Profile Transformations ********************/
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index ef1d5da56d8..93143eb7db3 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -488,6 +488,11 @@ float rgb_to_grayscale(float rgb[3])
return 0.3f*rgb[0] + 0.58f*rgb[1] + 0.12f*rgb[2];
}
+unsigned char rgb_to_grayscale_byte(unsigned char rgb[3])
+{
+ return (76*(unsigned short)rgb[0] + 148*(unsigned short)rgb[1] + 31*(unsigned short)rgb[2]) / 255;
+}
+
/* ********************************* lift/gamma/gain / ASC-CDL conversion ********************************* */
void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *offset, float *slope, float *power)