Merge with -r 22620:23107.
[blender.git] / source / blender / nodes / intern / CMP_util.c
index f9805645115002e6c32b457c82ac165c020c16c6..b396d5549d7731539739a9b693006303d000699e 100644 (file)
@@ -1104,9 +1104,23 @@ void qd_getPixel(CompBuf* src, int x, int y, float* col)
 {
        if ((x >= 0) && (x < src->x) && (y >= 0) && (y < src->y)) {
                float* bc = &src->rect[(x + y*src->x)*src->type];
-               col[0] = bc[0], col[1] = bc[1], col[2] = bc[2];
+               switch(src->type){
+                       /* these fallthrough to get all the channels */
+                       case CB_RGBA: col[3]=bc[3]; 
+                       case CB_VEC3: col[2]=bc[2];
+                       case CB_VEC2: col[1]=bc[1];
+                       case CB_VAL: col[0]=bc[0];
+               }
+       }
+       else {
+               switch(src->type){
+                       /* these fallthrough to get all the channels */
+                       case CB_RGBA: col[3]=0.0; 
+                       case CB_VEC3: col[2]=0.0; 
+                       case CB_VEC2: col[1]=0.0; 
+                       case CB_VAL: col[0]=0.0; 
+               }
        }
-       else col[0] = col[1] = col[2] = 0.f;
 }
 
 // sets pixel (x, y) to color col
@@ -1114,7 +1128,13 @@ void qd_setPixel(CompBuf* src, int x, int y, float* col)
 {
        if ((x >= 0) && (x < src->x) && (y >= 0) && (y < src->y)) {
                float* bc = &src->rect[(x + y*src->x)*src->type];
-               bc[0] = col[0], bc[1] = col[1], bc[2] = col[2];
+               switch(src->type){
+                       /* these fallthrough to get all the channels */
+                       case CB_RGBA: bc[3]=col[3]; 
+                       case CB_VEC3: bc[2]=col[2];
+                       case CB_VEC2: bc[1]=col[1];
+                       case CB_VAL: bc[0]=col[0];
+               }
        }
 }