From 4a43099c5a61f302654b7f309572505894357227 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 10 Oct 2007 23:34:40 +0000 Subject: Peach request new option for the image sequencer's image strips, flip x/y, (useful when making animatics to test the direction characters walk across the screen) added IMB_flipy was alredy there, needed to add IMB_flipx. --- source/blender/imbuf/IMB_imbuf.h | 8 ++++++++ source/blender/imbuf/intern/rotate.c | 26 ++++++++++++++++++++++++++ source/blender/makesdna/DNA_sequence_types.h | 2 ++ source/blender/src/drawseq.c | 12 ++++++++---- source/blender/src/sequence.c | 2 ++ 5 files changed, 46 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index e56fb5a776d..11cdebe70c3 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -417,6 +417,14 @@ void bilinear_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float */ void IMB_convert_bgra_to_rgba(int size, unsigned int *rect); +/** + * Flip the image X/Y + * + * @attention Defined in imageprocess.c + */ +void IMB_xflip(struct ImBuf *ibuf); +void IMB_yflip(struct ImBuf *ibuf); + /** * * @attention defined in scaling.c diff --git a/source/blender/imbuf/intern/rotate.c b/source/blender/imbuf/intern/rotate.c index 13edfbf0a33..4654dd6aefa 100644 --- a/source/blender/imbuf/intern/rotate.c +++ b/source/blender/imbuf/intern/rotate.c @@ -86,3 +86,29 @@ void IMB_flipy(struct ImBuf * ibuf) MEM_freeN(line); if(linef) MEM_freeN(linef); } + +void IMB_flipx(struct ImBuf * ibuf) +{ + short x, y, xr, xl, yi; + unsigned int px; + float px_f[4]; + + if (ibuf == NULL) return; + if (ibuf->rect == NULL) return; + + x = ibuf->x; + y = ibuf->y; + for(yi=y-1;yi>=0;yi--) { + for(xr=x-1, xl=0; xr>=xl; xr--, xl++) { + px = ibuf->rect[(x*yi)+xr]; + ibuf->rect[(x*yi)+xr] = ibuf->rect[(x*yi)+xl]; + ibuf->rect[(x*yi)+xl] = px; + + if (ibuf->rect_float) { + memcpy(&px_f, &ibuf->rect_float[((x*yi)+xr)*4], 4*sizeof(float)); + memcpy(&ibuf->rect_float[((x*yi)+xr)*4], &ibuf->rect_float[((x*yi)+xl)*4], 4*sizeof(float)); + memcpy(&ibuf->rect_float[((x*yi)+xl)*4], &px_f, 4*sizeof(float)); + } + } + } +} diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 5db102e9868..f1abc2dc0c8 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -205,6 +205,8 @@ typedef struct SpeedControlVars { #define SEQ_IPO_FRAME_LOCKED 256 #define SEQ_EFFECT_NOT_LOADED 512 #define SEQ_FLAG_DELETE 1024 +#define SEQ_FLIPX 2048 +#define SEQ_FLIPY 4096 /* seq->type WATCH IT: SEQ_EFFECT BIT is used to determine if this is an effect strip!!! */ #define SEQ_IMAGE 0 diff --git a/source/blender/src/drawseq.c b/source/blender/src/drawseq.c index af08af30fc8..7986a6da19a 100644 --- a/source/blender/src/drawseq.c +++ b/source/blender/src/drawseq.c @@ -1117,12 +1117,16 @@ static void seq_panel_properties(short cntrl) // SEQ_HANDLER_PROPERTIES } else if(last_seq->type==SEQ_IMAGE) { - uiDefBut(block, LABEL, 0, "Type: Image", 10,140,150,20, 0, 0, 0, 0, 0, ""); - uiDefBut(block, TEX, B_NOP, "Name: ", 10,120,150,19, last_seq->name+2, 0.0, 21.0, 100, 0, ""); + uiDefBut(block, LABEL, 0, "Type: Image", 10,160,150,20, 0, 0, 0, 0, 0, ""); + uiDefBut(block, TEX, B_NOP, "Name: ", 10,140,150,19, last_seq->name+2, 0.0, 21.0, 100, 0, ""); uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, SEQ_MAKE_PREMUL, SEQ_BUT_RELOAD, "Convert to Premul", 10,90,150,19, &last_seq->flag, 0.0, 21.0, 100, 0, "Converts RGB values to become premultiplied with Alpha"); - uiDefButBitS(block, TOG, SEQ_FILTERY, SEQ_BUT_RELOAD, "FilterY", 10,70,150,19, &last_seq->flag, 0.0, 21.0, 100, 0, "For video movies to remove fields"); + uiDefButBitS(block, TOG, SEQ_MAKE_PREMUL, SEQ_BUT_RELOAD, "Convert to Premul", 10,110,150,19, &last_seq->flag, 0.0, 21.0, 100, 0, "Converts RGB values to become premultiplied with Alpha"); + uiDefButBitS(block, TOG, SEQ_FILTERY, SEQ_BUT_RELOAD, "FilterY", 10,90,150,19, &last_seq->flag, 0.0, 21.0, 100, 0, "For video movies to remove fields"); + + uiDefButBitS(block, TOG, SEQ_FLIPX, SEQ_BUT_RELOAD, "FlipX", 10,70,75,19, &last_seq->flag, 0.0, 21.0, 100, 0, "Flip on the X axis"); + uiDefButBitS(block, TOG, SEQ_FLIPY, SEQ_BUT_RELOAD, "FlipY", 85,70,75,19, &last_seq->flag, 0.0, 21.0, 100, 0, "Flip on the Y axis"); + uiDefButF(block, NUM, SEQ_BUT_RELOAD, "Mul:", 10,50,150,19, &last_seq->mul, 0.001, 5.0, 100, 0, "Multiply colors"); uiDefButS(block, TOG|BIT|7, SEQ_BUT_RELOAD, "Reverse Frames", 10,30,150,19, &last_seq->flag, 0.0, 21.0, 100, 0, "Reverse frame order"); uiDefButF(block, NUM, SEQ_BUT_RELOAD, "Strobe:", 10,10,150,19, &last_seq->strobe, 1.0, 30.0, 100, 0, "Only display every nth frame"); diff --git a/source/blender/src/sequence.c b/source/blender/src/sequence.c index e55cea7de59..f9ad78dc732 100644 --- a/source/blender/src/sequence.c +++ b/source/blender/src/sequence.c @@ -779,6 +779,8 @@ static void do_build_seq_ibuf(Sequence * seq, int cfra) seq->strip->orx= se->ibuf->x; seq->strip->ory= se->ibuf->y; if(seq->flag & SEQ_FILTERY) IMB_filtery(se->ibuf); + if(seq->flag & SEQ_FLIPX) IMB_flipx(se->ibuf); + if(seq->flag & SEQ_FLIPY) IMB_flipy(se->ibuf); if(seq->mul==0.0) seq->mul= 1.0; if(seq->mul != 1.0) multibuf(se->ibuf, seq->mul); } -- cgit v1.2.3