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:
Diffstat (limited to 'source/blender/imbuf/intern/rectop.c')
-rw-r--r--source/blender/imbuf/intern/rectop.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c
index 44af7ffdb3f..db2ae3a5114 100644
--- a/source/blender/imbuf/intern/rectop.c
+++ b/source/blender/imbuf/intern/rectop.c
@@ -450,7 +450,7 @@ void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx,
/* fill */
-void IMB_rectfill(struct ImBuf *drect, float col[4])
+void IMB_rectfill(struct ImBuf *drect, const float col[4])
{
int num;
@@ -482,7 +482,7 @@ void IMB_rectfill(struct ImBuf *drect, float col[4])
}
-void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2)
+void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, const float col[4], int x1, int y1, int x2, int y2)
{
int i, j;
float a; /* alpha */
@@ -509,6 +509,8 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
unsigned char *pixel;
unsigned char chr=0, chg=0, chb=0;
float fr=0, fg=0, fb=0;
+
+ const int alphaint= FTOCHAR(a);
if (a == 1.0f) {
chr = FTOCHAR(col[0]);
@@ -527,10 +529,13 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
pixel[0] = chr;
pixel[1] = chg;
pixel[2] = chb;
+ pixel[3] = 255;
} else {
+ int alphatest;
pixel[0] = (char)((fr + ((float)pixel[0]*aich))*255.0f);
pixel[1] = (char)((fg + ((float)pixel[1]*aich))*255.0f);
pixel[2] = (char)((fb + ((float)pixel[2]*aich))*255.0f);
+ pixel[3] = (char)((alphatest= ((int)pixel[3] + alphaint)) < 255 ? alphatest : 255);
}
}
}
@@ -546,10 +551,13 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
pixel[0] = col[0];
pixel[1] = col[1];
pixel[2] = col[2];
+ pixel[3] = 1.0f;
} else {
+ float alphatest;
pixel[0] = (col[0]*a) + (pixel[0]*ai);
pixel[1] = (col[1]*a) + (pixel[1]*ai);
pixel[2] = (col[2]*a) + (pixel[2]*ai);
+ pixel[3] = (alphatest= (pixel[3] + a)) < 1.0f ? alphatest : 1.0f;
}
}
}
@@ -561,3 +569,18 @@ void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, i
if (!ibuf) return;
buf_rectfill_area((unsigned char *) ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, col, x1, y1, x2, y2);
}
+
+
+void IMB_rectfill_alpha(ImBuf *ibuf, const float value)
+{
+ int i;
+ if (ibuf->rect_float) {
+ float *fbuf= ibuf->rect_float + 3;
+ for (i = ibuf->x * ibuf->y; i > 0; i--, fbuf+= 4) { *fbuf = value; }
+ }
+ else {
+ const unsigned char cvalue= value * 255;
+ unsigned char *cbuf= ((unsigned char *)ibuf->rect) + 3;
+ for (i = ibuf->x * ibuf->y; i > 0; i--, cbuf+= 4) { *cbuf = cvalue; }
+ }
+}