X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fmodules%2Fswfshape.c;h=18e9b6b312942d2e6c1cf5e478691582fdd9c893;hb=714b122c75a757dcd1ef9a631aa209a298e650d7;hp=5b45d261148349e13bfcacf724f8e77f2c1a00e8;hpb=b3f71329c1865093a9f0183086149e52c8f804c4;p=swftools.git diff --git a/lib/modules/swfshape.c b/lib/modules/swfshape.c index 5b45d26..18e9b6b 100644 --- a/lib/modules/swfshape.c +++ b/lib/modules/swfshape.c @@ -7,9 +7,19 @@ Copyright (c) 2001 Rainer Böhme - This file is distributed under the GPL, see file COPYING for details + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -*/ + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define SF_MOVETO 0x01 #define SF_FILL0 0x02 @@ -172,6 +182,11 @@ int swf_SetFillStyle(TAG * t,FILLSTYLE * f) swf_SetU16(t,f->id_bitmap); swf_SetMatrix(t,&f->m); break; + case FILL_LINEAR: + case FILL_RADIAL: + swf_SetMatrix(t,&f->m); + swf_SetGradient(t,&f->gradient,/*alpha?*/t->id==ST_DEFINESHAPE3?1:0); + break; } return 0; @@ -242,63 +257,10 @@ int swf_SetShapeHeader(TAG * t,SHAPE * s) return res; } -int swf_ShapeExport(int handle,SHAPE * s) // without Linestyle/Fillstyle Record -{ int l; - if (!s) return 0; - - l = sizeof(SHAPE); - - if (handle>=0) - if (write(handle,s,sizeof(SHAPE))!=sizeof(SHAPE)) return -1; - - // Fillstyle, Linestyle ... - - if (s->data) - { int ll = (s->bitlen+7)/8; - l+=ll; - if (handle>=0) - if (write(handle,s->data,ll)!=ll) return -1; - } - - return l; -} - -int swf_ShapeImport(int handle,SHAPE * * shape) -{ SHAPE * s; - - if (handle<0) return -1; - - s = (SHAPE *)malloc(sizeof(SHAPE)); shape[0] = s; - if (!s) return -1; - - if (read(handle,s,sizeof(SHAPE))!=sizeof(SHAPE)) - { shape[0] = NULL; - free(s); - return -1; - } - - if (s->data) - { int ll = (s->bitlen+7)/8; - s->data = (U8*)malloc(ll); - if (!s->data) - { shape[0] = NULL; - free(s); - return -1; - } - if (read(handle,s->data,ll)!=ll) - { free(s->data); - free(s); - shape[0] = NULL; - return -1; - } - } - - return 0; -} - -int swf_ShapeAddFillStyle(SHAPE * s,U8 type,MATRIX * m,RGBA * color,U16 id_bitmap) +int swf_ShapeAddFillStyle(SHAPE * s,U8 type,MATRIX * m,RGBA * color,U16 id_bitmap, GRADIENT*gradient) { RGBA def_c; MATRIX def_m; + GRADIENT def_g; // handle defaults @@ -312,6 +274,11 @@ int swf_ShapeAddFillStyle(SHAPE * s,U8 type,MATRIX * m,RGBA * color,U16 id_bitma { m = &def_m; swf_GetMatrix(NULL,m); } + if(!gradient) + { + gradient = &def_g; + swf_GetGradient(NULL, gradient, 1); + } // handle memory @@ -332,16 +299,21 @@ int swf_ShapeAddFillStyle(SHAPE * s,U8 type,MATRIX * m,RGBA * color,U16 id_bitma s->fillstyle.data[s->fillstyle.n].id_bitmap = id_bitmap; memcpy(&s->fillstyle.data[s->fillstyle.n].m,m,sizeof(MATRIX)); memcpy(&s->fillstyle.data[s->fillstyle.n].color,color,sizeof(RGBA)); + memcpy(&s->fillstyle.data[s->fillstyle.n].gradient,gradient,sizeof(GRADIENT)); return (++s->fillstyle.n); } int swf_ShapeAddSolidFillStyle(SHAPE * s,RGBA * color) -{ return swf_ShapeAddFillStyle(s,FILL_SOLID,NULL,color,0); +{ return swf_ShapeAddFillStyle(s,FILL_SOLID,NULL,color,0,0); } int swf_ShapeAddBitmapFillStyle(SHAPE * s,MATRIX * m,U16 id_bitmap,int clip) -{ return swf_ShapeAddFillStyle(s,clip?FILL_CLIPPED:FILL_TILED,m,NULL,id_bitmap); +{ return swf_ShapeAddFillStyle(s,clip?FILL_CLIPPED:FILL_TILED,m,NULL,id_bitmap,0); +} + +int swf_ShapeAddGradientFillStyle(SHAPE * s,MATRIX * m,GRADIENT* gradient,int radial) +{ return swf_ShapeAddFillStyle(s,radial?FILL_RADIAL:FILL_LINEAR,m,NULL,0,gradient); } int swf_ShapeAddLineStyle(SHAPE * s,U16 width,RGBA * color) @@ -385,7 +357,7 @@ int swf_ShapeSetMove(TAG * t,SHAPE * s,S32 x,S32 y) return 0; } -int swf_ShapeSetStyle(TAG * t,SHAPE * s,U16 line,U16 fill0,U16 fill1) +int swf_ShapeSetStyle(TAG * t,SHAPE * s,int line,int fill0,int fill1) { if ((!t)||(!s)) return -1; swf_SetBits(t,0,1); @@ -404,11 +376,9 @@ int swf_ShapeSetStyle(TAG * t,SHAPE * s,U16 line,U16 fill0,U16 fill1) these defines are a workaround (they also reduce the maximal number of fill styles to 32768) */ -#define FILL_RESET 0x8000 -#define LINE_RESET 0x8000 #define UNDEFINED_COORD 0x7fffffff -int swf_ShapeSetAll(TAG * t,SHAPE * s,S32 x,S32 y,U16 line,U16 fill0,U16 fill1) +int swf_ShapeSetAll(TAG * t,SHAPE * s,S32 x,S32 y,int line,int fill0,int fill1) { U8 b; U8 hasmove = 0; if ((!t)||(!s)) return -1; @@ -641,8 +611,6 @@ SRECT swf_GetShapeBoundingBox(SHAPE2*shape2) { SRECT r; SHAPELINE*l = shape2->lines; - int SCOORD_MAX = 0x7fffffff; - int SCOORD_MIN = -0x80000000; int lastx=0,lasty=0; int valid = 0; r.xmin = r.ymin = SCOORD_MAX; @@ -722,7 +690,7 @@ void swf_ShapeSetBitmapRect(TAG*tag, U16 gfxid, int width, int height) RGBA rgb; SRECT r; int lines = 0; - int ls,fs; + int ls=0,fs; swf_ShapeNew(&shape); rgb.b = rgb.g = rgb.r = 0xff; if(lines)