use color conversions functions in more places.

also add rgba_float_to_uchar, rgba_uchar_to_float
This commit is contained in:
2012-01-19 10:04:51 +00:00
parent 47514a0d71
commit a87c5eb52c
13 changed files with 72 additions and 85 deletions

View File

@@ -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++) {