diff options
author | Ton Roosendaal <ton@blender.org> | 2006-02-18 17:35:43 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-02-18 17:35:43 +0300 |
commit | 1ea90994744cb95d83717bb7df972c693f9e9583 (patch) | |
tree | d803ddef0effd29024cfb71e8d81ee41f6b52a1d /source/blender/imbuf/intern/divers.c | |
parent | 7425a8fcaa3a777155d7b75d368db3b0ed1e58a4 (diff) |
- Restored "dither" option for conversion from float -> byte images.
This now is a post-process option only (used to be in render).
It is only handled within the Imbuf/ module, on conversions from float
to byte rect, which atm mostly happens on saving images.
- Small fix: when using Scene RenderLayer nodes, the speed vectors for
these nodes were not created when that scene had "Do Composite" off.
Diffstat (limited to 'source/blender/imbuf/intern/divers.c')
-rw-r--r-- | source/blender/imbuf/intern/divers.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index 71292e27611..2fc80f6ddcb 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -33,6 +33,7 @@ */ #include "BLI_blenlib.h" +#include "BLI_rand.h" #include "imbuf.h" #include "imbuf_patch.h" @@ -172,6 +173,7 @@ void IMB_rect_from_float(struct ImBuf *ibuf) { /* quick method to convert floatbuf to byte */ float *tof = ibuf->rect_float; + float dither= ibuf->dither; int i; unsigned char *to = (unsigned char *) ibuf->rect; @@ -181,14 +183,33 @@ void IMB_rect_from_float(struct ImBuf *ibuf) to = (unsigned char *) ibuf->rect; } - for (i = ibuf->x * ibuf->y; i > 0; i--) - { - to[0] = FTOCHAR(tof[0]); - to[1] = FTOCHAR(tof[1]); - to[2] = FTOCHAR(tof[2]); - to[3] = FTOCHAR(tof[3]); - to += 4; - tof += 4; + if(dither==0.0f) { + for (i = ibuf->x * ibuf->y; i > 0; i--) { + to[0] = FTOCHAR(tof[0]); + to[1] = FTOCHAR(tof[1]); + to[2] = FTOCHAR(tof[2]); + to[3] = FTOCHAR(tof[3]); + to += 4; + tof += 4; + } + } + else { + float dither_value, col; + dither= dither/255.0f; + for (i = ibuf->x * ibuf->y; i > 0; i--) { + dither_value = (BLI_frand()-0.5)*dither; + col= tof[0] + dither_value; + to[0] = FTOCHAR(col); + col= tof[1] + dither_value; + to[1] = FTOCHAR(col); + col= tof[2] + dither_value; + to[2] = FTOCHAR(col); + col= tof[3] + dither_value; + to[3] = FTOCHAR(col); + + to += 4; + tof += 4; + } } } |