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>2012-01-19 14:04:51 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-01-19 14:04:51 +0400
commita87c5eb52cd4951b138f518bf12d498bc5e5eb8a (patch)
tree7b023285cb2ff41924d9e390f3d6a25715284d14 /source/blender/blenkernel/intern
parent47514a0d7129ba49cd9ad039a886c52909ea565d (diff)
use color conversions functions in more places.
also add rgba_float_to_uchar, rgba_uchar_to_float
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/brush.c31
-rw-r--r--source/blender/blenkernel/intern/image_gen.c15
-rw-r--r--source/blender/blenkernel/intern/node.c5
3 files changed, 18 insertions, 33 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 362fa6e5e9a..f2514c1030b 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -527,7 +527,7 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall,
float xy[2], rgba[4], *dstf;
int x, y, rowbytes, xoff, yoff, imbflag;
const int radius= brush_size(scene, brush);
- char *dst, crgb[3];
+ unsigned char *dst, crgb[3];
const float alpha= brush_alpha(scene, brush);
float brush_rgb[3];
@@ -571,10 +571,10 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall,
}
else {
float alpha_f; /* final float alpha to convert to char */
- F3TOCHAR3(brush->rgb, crgb);
+ rgb_float_to_uchar(crgb, brush->rgb);
for (y=0; y < ibuf->y; y++) {
- dst = (char*)ibuf->rect + y*rowbytes;
+ dst = (unsigned char *)ibuf->rect + y*rowbytes;
for (x=0; x < ibuf->x; x++, dst+=4) {
xy[0] = x + xoff;
@@ -590,19 +590,15 @@ void brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall,
}
else if (texfall == 1) {
brush_sample_tex(scene, brush, xy, rgba, 0);
- dst[0] = FTOCHAR(rgba[0]);
- dst[1] = FTOCHAR(rgba[1]);
- dst[2] = FTOCHAR(rgba[2]);
- dst[3] = FTOCHAR(rgba[3]);
+ rgba_float_to_uchar(dst, rgba);
}
else if (texfall == 2) {
brush_sample_tex(scene, brush, xy, rgba, 0);
mul_v3_v3(rgba, brush->rgb);
alpha_f = rgba[3] * alpha * brush_curve_strength_clamp(brush, len_v2(xy), radius);
- dst[0] = FTOCHAR(rgba[0]);
- dst[1] = FTOCHAR(rgba[1]);
- dst[2] = FTOCHAR(rgba[2]);
+ rgb_float_to_uchar(dst, rgba);
+
dst[3] = FTOCHAR(alpha_f);
}
else {
@@ -843,7 +839,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i
Brush *brush= painter->brush;
ImBuf *ibuf, *maskibuf, *texibuf;
float *bf, *mf, *tf, *otf=NULL, xoff, yoff, xy[2], rgba[4];
- char *b, *m, *t, *ot= NULL;
+ unsigned char *b, *m, *t, *ot= NULL;
int dotexold, origx= x, origy= y;
const int radius= brush_size(painter->scene, brush);
@@ -895,12 +891,12 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i
}
else {
for (; y < h; y++) {
- b = (char*)ibuf->rect + (y*ibuf->x + origx)*4;
- t = (char*)texibuf->rect + (y*texibuf->x + origx)*4;
- m = (char*)maskibuf->rect + (y*maskibuf->x + origx)*4;
+ b = (unsigned char *)ibuf->rect + (y*ibuf->x + origx)*4;
+ t = (unsigned char *)texibuf->rect + (y*texibuf->x + origx)*4;
+ m = (unsigned char *)maskibuf->rect + (y*maskibuf->x + origx)*4;
if (dotexold)
- ot = (char*)oldtexibuf->rect + ((y - origy + yt)*oldtexibuf->x + xt)*4;
+ ot = (unsigned char *)oldtexibuf->rect + ((y - origy + yt)*oldtexibuf->x + xt)*4;
for (x=origx; x < w; x++, b+=4, m+=4, t+=4) {
if (dotexold) {
@@ -915,10 +911,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i
xy[1] = y + yoff;
brush_sample_tex(scene, brush, xy, rgba, 0);
- t[0]= FTOCHAR(rgba[0]);
- t[1]= FTOCHAR(rgba[1]);
- t[2]= FTOCHAR(rgba[2]);
- t[3]= FTOCHAR(rgba[3]);
+ rgba_float_to_uchar(t, rgba);
}
b[0] = t[0]*m[0]/255;
diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c
index a93d0221cf0..c6cb8c9582a 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -33,7 +33,7 @@
#include "BLI_math_base.h"
#include "BLF_api.h"
-void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, int height, float color[4])
+void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, int height, const float color[4])
{
int x, y;
@@ -41,22 +41,17 @@ void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width,
if(rect_float) {
for(y= 0; y<height; y++) {
for(x= 0; x<width; x++) {
- rect_float[0]= color[0];
- rect_float[1]= color[1];
- rect_float[2]= color[2];
- rect_float[3]= color[3];
+ copy_v4_v4(rect_float, color);
rect_float+= 4;
}
}
}
if(rect) {
- char ccol[4];
+ unsigned char ccol[4];
+
+ rgba_float_to_uchar(ccol, color);
- ccol[0]= (char)(color[0]*255.0f);
- ccol[1]= (char)(color[1]*255.0f);
- ccol[2]= (char)(color[2]*255.0f);
- ccol[3]= (char)(color[3]*255.0f);
for(y= 0; y<height; y++) {
for(x= 0; x<width; x++) {
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 61111e82cc7..a2d7d9b502c 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -793,10 +793,7 @@ void nodeAddToPreview(bNode *node, float *col, int x, int y, int do_manage)
linearrgb_to_srgb_uchar4(tar, col);
}
else {
- tar[0]= FTOCHAR(col[0]);
- tar[1]= FTOCHAR(col[1]);
- tar[2]= FTOCHAR(col[2]);
- tar[3]= FTOCHAR(col[3]);
+ rgba_float_to_uchar(tar, col);
}
}
//else printf("prv out bound x y %d %d\n", x, y);