Index: source/blender/makesdna/DNA_sequence_types.h =================================================================== --- source/blender/makesdna/DNA_sequence_types.h (revisión: 12468) +++ source/blender/makesdna/DNA_sequence_types.h (copia de trabajo) @@ -233,7 +233,7 @@ #define SEQ_TRANSFORM 27 #define SEQ_COLOR 28 #define SEQ_SPEED 29 +#define SEQ_GRAY 30 - #endif Index: source/blender/src/seqeffects.c =================================================================== --- source/blender/src/seqeffects.c (revisión: 12468) +++ source/blender/src/seqeffects.c (copia de trabajo) @@ -1902,6 +1902,57 @@ (unsigned char*) out->rect); } } +/* ********************************************************************* + GRAY (Image RGB to Gray) + ********************************************************************* */ +static int num_inputs_gray() +{ + return 1; +} + +static void do_gray_effect_float(Sequence *seq, float facf0, float facf1, + int x, int y, float *rect1, float *out) +{ + int a, b; + float val; + for(a= x*y-1, b=a*4; a>=0; a--, b-=4) + { + val=(rect1[b]+rect1[b+1]+rect1[b+2])/3.0f; + out[b]=out[b+1]=out[b+2]=val; + out[b+3]=rect1[b+3]; + } +} + +static void do_gray_effect_byte(Sequence *seq, float facf0, float facf1, + int x, int y, unsigned char *rect1, unsigned char *out) +{ + int a, b; + unsigned char val; + for(a= x*y-1, b=a*4; a>=0; a--, b-=4) + { + val=(rect1[b]+rect1[b+1]+rect1[b+2])/3; + out[b]=out[b+1]=out[b+2]=val; + out[b+3]=rect1[b+3]; + } +} +static void do_gray_effect(Sequence * seq,int cfra, + float facf0, float facf1, int x, int y, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3, struct ImBuf *out) +{ + if (out->rect_float) { + do_gray_effect_float(seq, + facf0, facf1, x, y, + ibuf1->rect_float, + out->rect_float); + } else { + do_gray_effect_byte(seq, + facf0, facf1, x, y, + (unsigned char*) ibuf1->rect, + (unsigned char*) out->rect); + } + +} /* ********************************************************************** TRANSFORM ********************************************************************** */ @@ -2993,6 +3044,10 @@ rval.copy = copy_solid_color; rval.execute = do_solid_color; break; + case SEQ_GRAY: + rval.num_inputs = num_inputs_gray; + rval.execute = do_gray_effect; + break; case SEQ_PLUGIN: rval.init_plugin = init_plugin; rval.num_inputs = num_inputs_plugin; Index: source/blender/src/editseq.c =================================================================== --- source/blender/src/editseq.c (revisión: 12468) +++ source/blender/src/editseq.c (copia de trabajo) @@ -1541,6 +1541,7 @@ if(event==15) return SEQ_TRANSFORM; if(event==16) return SEQ_COLOR; if(event==17) return SEQ_SPEED; + if(event==18) return SEQ_GRAY; return 0; } @@ -1769,6 +1770,9 @@ case SEQ_SPEED: event = 17; break; + case SEQ_GRAY: + event = 18; + break; default: event = 0; break; @@ -1799,7 +1803,8 @@ "|Glow%x14" "|Transforms%x15" "|Color Generator%x16" - "|Speed Control%x17"); + "|Speed Control%x17" + "|Gray%x18"); } if(event<1) return; @@ -1883,6 +1888,7 @@ case 15: case 16: case 17: + case 18: if(get_last_seq()==0 && get_sequence_effect_num_inputs( event_to_efftype(event))> 0) error("Need at least one active sequence strip"); @@ -1929,7 +1935,8 @@ "|Glow%x14" "|Transform%x15" "|Color Generator%x16" - "|Speed Control%x17"); + "|Speed Control%x17" + "|Gray%x18"); if(event > 0) { if(event==1) { SWAP(Sequence *,last_seq->seq1,last_seq->seq2); Index: source/blender/src/header_seq.c =================================================================== --- source/blender/src/header_seq.c (revisión: 12468) +++ source/blender/src/header_seq.c (copia de trabajo) @@ -279,6 +279,8 @@ case 13: add_sequence(SEQ_SPEED); break; + case 14: + add_sequence(SEQ_GRAY); } } @@ -303,6 +305,7 @@ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Transform", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 11, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Color Generator", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 12, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Speed Control", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 13, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Gray", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 14, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Plugin...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, ""); Index: source/blender/src/drawseq.c =================================================================== --- source/blender/src/drawseq.c (revisión: 12468) +++ source/blender/src/drawseq.c (copia de trabajo) @@ -121,6 +121,7 @@ else if(seq->type==SEQ_TRANSFORM) return "Transform"; else if(seq->type==SEQ_COLOR) return "Color"; else if(seq->type==SEQ_SPEED) return "Speed"; + else if(seq->type==SEQ_GRAY) return "Gray scale"; else if(seq->type==SEQ_PLUGIN) { if(!(seq->flag & SEQ_EFFECT_NOT_LOADED) && seq->plugin && seq->plugin->doit) return seq->plugin->pname; @@ -184,6 +185,7 @@ break; /* effects */ + case SEQ_GRAY: case SEQ_TRANSFORM: case SEQ_SPEED: case SEQ_ADD: @@ -207,7 +209,7 @@ if (seq->type == SEQ_OVERDROP) hsv[0]+= 0.24; if (seq->type == SEQ_GLOW) hsv[0]+= 0.28; if (seq->type == SEQ_TRANSFORM) hsv[0]+= 0.36; - + if (seq->type == SEQ_GRAY) hsv[0]+= 0.40; if(hsv[0]>1.0) hsv[0]-=1.0; else if(hsv[0]<0.0) hsv[0]+= 1.0; hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); col[0] = (char)(rgb[0]*255); col[1] = (char)(rgb[1]*255); col[2] = (char)(rgb[2]*255);