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:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-01-05 19:33:18 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-01-05 19:33:18 +0400
commitfa0805e287e762df3638df1982297c794c4cf4b7 (patch)
tree1b2a7d612bde64569aad2afd72410a43a8147f27 /source/blender/imbuf/intern/imageprocess.c
parente8b415bdb4ba282e3574cad1463bf2512fe5eb8f (diff)
Changes for opengl render to reflect new alpha premul pipeline
without hurting quick texture painting - ED_view3d_draw_offscreen will now output buffer with transparent alpha, if sky needed it should be alpha-undered later. - ED_view3d_draw_offscreen_imbuf now accepts alpha mode as an argument which could be either R_ADDSKY or R_PREMULALPHA - OpenGL render and sequencer's opengl preview will now reflect scene's Alpha Mode - Quick Edit will use OpenGL with transparent alpha mode
Diffstat (limited to 'source/blender/imbuf/intern/imageprocess.c')
-rw-r--r--source/blender/imbuf/intern/imageprocess.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index 1eac6236829..59282c9d207 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -327,3 +327,53 @@ void IMB_processor_apply_threaded(int buffer_lines, int handle_size, void *init_
MEM_freeN(handles);
}
+
+/* Alpha-under */
+
+void IMB_alpha_under_color_float(float *rect_float, int x, int y, float backcol[3])
+{
+ int a = x * y;
+ float *fp = rect_float;
+
+ while (a--) {
+ if (fp[3] == 0.0f) {
+ copy_v3_v3(fp, backcol);
+ }
+ else {
+ float mul = 1.0f - fp[3];
+
+ fp[0] += mul * backcol[0];
+ fp[1] += mul * backcol[1];
+ fp[2] += mul * backcol[2];
+ }
+
+ fp[3] = 1.0f;
+
+ fp += 4;
+ }
+}
+
+void IMB_alpha_under_color_byte(unsigned char *rect, int x, int y, float backcol[3])
+{
+ int a = x * y;
+ unsigned char *cp = rect;
+
+ while (a--) {
+ if (cp[3] == 0) {
+ cp[0] = backcol[0] * 255;
+ cp[1] = backcol[1] * 255;
+ cp[2] = backcol[2] * 255;
+ }
+ else {
+ int mul = 255 - cp[3];
+
+ cp[0] += mul * backcol[0] / 255;
+ cp[1] += mul * backcol[1] / 255;
+ cp[2] += mul * backcol[2] / 255;
+ }
+
+ cp[3] = 255;
+
+ cp += 4;
+ }
+}