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/imbuf
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/imbuf')
-rw-r--r--source/blender/imbuf/IMB_imbuf.h1
-rw-r--r--source/blender/imbuf/intern/divers.c20
2 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index e9592fdc164..ff01e3a8a1e 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -338,6 +338,7 @@ void IMB_float_from_rect_simple(struct ImBuf *ibuf); /* no profile conversion */
/* note, check that the conversion exists, only some are supported */
void IMB_convert_profile(struct ImBuf *ibuf, int profile);
float *IMB_float_profile_ensure(struct ImBuf *ibuf, int profile, int *alloc);
+void IMB_color_to_bw(struct ImBuf *ibuf);
/**
* Change the ordering of the color bytes pointed to by rect from
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 90ee2692cf0..7fc7669601d 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -490,3 +490,23 @@ float *IMB_float_profile_ensure(struct ImBuf *ibuf, int profile, int *alloc)
return fbuf;
}
}
+
+
+/* no profile conversion */
+void IMB_color_to_bw(struct ImBuf *ibuf)
+{
+ float *rctf= ibuf->rect_float;
+ unsigned char *rct= (unsigned char *)ibuf->rect;
+ int i;
+ if(rctf) {
+ for (i = ibuf->x * ibuf->y; i > 0; i--, rctf+=4) {
+ rctf[0]= rctf[1]= rctf[2]= rgb_to_grayscale(rctf);
+ }
+ }
+
+ if(rct) {
+ for (i = ibuf->x * ibuf->y; i > 0; i--, rct+=4) {
+ rct[0]= rct[1]= rct[2]= rgb_to_grayscale_byte(rct);
+ }
+ }
+}