X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Frfxswf.h;h=a86943d2f27b63464998d41607a63f3cf746b3dd;hb=f72efb3e0b08321fe70a478bf939c312ed7564ce;hp=548e67935366f5f5102962f4a8504d15d2865871;hpb=6d22f1376c2fcad7c872db608630468d3abcca23;p=swftools.git diff --git a/lib/rfxswf.h b/lib/rfxswf.h index 548e679..a86943d 100644 --- a/lib/rfxswf.h +++ b/lib/rfxswf.h @@ -30,6 +30,7 @@ extern "C" { #include #include +#include #include #include #include @@ -72,8 +73,14 @@ extern "C" { #endif #define ALLOC_ARRAY(type, num) (((type)*)rfxalloc(sizeof(type)*(num))) -void* rfxalloc(int size); -void rfxdealloc(void*data); +void* rfx_alloc(int size); +void* rfx_calloc(int size); +void* rfx_realloc(void*data, int size); +void rfx_free(void*data); +#ifdef MEMORY_INFO +long rfx_memory_used(); +char* rfx_memory_used_str(); +#endif // SWF Types @@ -94,14 +101,14 @@ typedef signed long SCOORD; typedef struct _SPOINT { SCOORD x; SCOORD y; -} SPOINT, * LPSPOINT; +} SPOINT; typedef struct _RGBA { U8 a; U8 r; U8 g; U8 b; -} RGBA, * LPRGBA; +} RGBA; typedef struct _YUV { @@ -113,23 +120,19 @@ typedef struct _SRECT SCOORD ymin; SCOORD xmax; SCOORD ymax; -} SRECT, * LPSRECT; +} SRECT; typedef struct _MATRIX -{ SFIXED sx; // factor x - SFIXED sy; - SFIXED r0; // rotation - SFIXED r1; - SCOORD tx; // delta x - SCOORD ty; -} MATRIX, * LPMATRIX; +{ SFIXED sx,r1, tx; + SFIXED r0,sy, ty; +} MATRIX; typedef struct _CXFORM { S16 a0, a1; /* mult, add */ S16 r0, r1; S16 g0, g1; S16 b0, b1; -} CXFORM, * LPCXFORM; +} CXFORM; #define GRADIENT_LINEAR 0x10 #define GRADIENT_RADIAL 0x12 @@ -154,7 +157,7 @@ typedef struct _TAG // NEVER access a Tag-Struct directly ! U8 readBit; // for Bit-Manipulating Functions [read] U8 writeBit; // [write] -} TAG, * LPTAG; +} TAG; #define swf_ResetReadBits(tag) if (tag->readBit) { tag->pos++; tag->readBit = 0; } #define swf_ResetWriteBits(tag) if (tag->writeBit) { tag->writeBit = 0; } @@ -184,7 +187,7 @@ typedef struct _SWF U16 frameRate; U16 frameCount; // valid after load and save TAG * firstTag; -} SWF, * LPSWF; +} SWF; // Basic Functions @@ -195,6 +198,7 @@ int swf_WriteSWF(int handle,SWF * swf); // Writes SWF to file, returns lengt int swf_WriteSWC(int handle, SWF * swf); // for convenience, equal to swf->compressed=1;swf_WriteSWF(..) int swf_WriteCGI(SWF * swf); // Outputs SWF with valid CGI header to stdout void swf_FreeTags(SWF * swf); // Frees all malloc'ed memory for swf +SWF* swf_CopySWF(SWF*swf); // for streaming: int swf_WriteHeader(int handle,SWF * swf); // Writes Header of swf to file @@ -354,7 +358,7 @@ SRECT swf_TurnRect(SRECT r, MATRIX* m); typedef struct _LINESTYLE { U16 width; RGBA color; -} LINESTYLE, * LPLINESTYLE; +} LINESTYLE; #define FILL_SOLID 0x00 #define FILL_LINEAR 0x10 // Gradient @@ -368,7 +372,7 @@ typedef struct _FILLSTYLE MATRIX m; U16 id_bitmap; GRADIENT gradient; -} FILLSTYLE, * LPFILLSTYLE; +} FILLSTYLE; typedef struct _SHAPE // NEVER access a Shape-Struct directly ! { @@ -389,7 +393,7 @@ typedef struct _SHAPE // NEVER access a Shape-Struct directly ! // used by Get/SetSimpleShape and glyph handling U8 * data; U32 bitlen; // length of data in bits -} SHAPE, * LPSHAPE; +} SHAPE; /* SHAPE can be converted into SHAPE2: */ @@ -427,6 +431,7 @@ int swf_ShapeAddLineStyle(SHAPE * s,U16 width,RGBA * color); int swf_ShapeAddSolidFillStyle(SHAPE * s,RGBA * color); int swf_ShapeAddBitmapFillStyle(SHAPE * s,MATRIX * m,U16 id_bitmap,int clip); int swf_ShapeAddGradientFillStyle(SHAPE * s,MATRIX * m,GRADIENT* gradient,int radial); +int swf_ShapeAddFillStyle2(SHAPE * s,FILLSTYLE*fs); int swf_SetShapeStyles(TAG * t,SHAPE * s); int swf_ShapeCountBits(SHAPE * s,U8 * fbits,U8 * lbits); @@ -435,6 +440,7 @@ int swf_SetShapeHeader(TAG * t,SHAPE * s); // one call for upper three functio int swf_ShapeSetMove(TAG * t,SHAPE * s,S32 x,S32 y); int swf_ShapeSetStyle(TAG * t,SHAPE * s,int line,int fill0,int fill1); +#define UNDEFINED_COORD 0x7fffffff int swf_ShapeSetAll(TAG * t,SHAPE * s,S32 x,S32 y,int line,int fill0,int fill1); int swf_ShapeSetLine(TAG * t,SHAPE * s,S32 x,S32 y); @@ -444,18 +450,21 @@ int swf_ShapeSetEnd(TAG * t); void swf_ShapeSetBitmapRect(TAG * t, U16 gfxid, int width, int height); -SHAPELINE* swf_ParseShapeData(U8*data, int bits, int fillbits, int linebits); +//SHAPELINE* swf_ParseShapeData(U8*data, int bits, int fillbits, int linebits); SHAPE2* swf_ShapeToShape2(SHAPE*shape); void swf_Shape2ToShape(SHAPE2*shape2, SHAPE*shape); SRECT swf_GetShapeBoundingBox(SHAPE2*shape); void swf_SetShape2(TAG*tag, SHAPE2*shape); +SHAPE2* swf_Shape2Clone(SHAPE2 * s); void swf_Shape2Free(SHAPE2 * s); void swf_DumpShape(SHAPE2*shape2); void swf_ParseDefineShape(TAG*tag, SHAPE2*shape); -void swf_Shape2ToShape(SHAPE2*shape2, SHAPE*shape); void swf_SetShape2(TAG*tag, SHAPE2*shape2); +void swf_RecodeShapeData(U8*data, int bitlen, int in_bits_fill, int in_bits_line, + U8**destdata, U32*destbitlen, int out_bits_fill, int out_bits_line); + // swfdraw.c void swf_Shape10DrawerInit(drawer_t*draw, TAG*tag); @@ -482,7 +491,7 @@ typedef struct _SWFLAYOUT SRECT * bounds; U16 kerningcount; SWFKERNING * kerning; -} SWFLAYOUT, * LPSWFLAYOUT; +} SWFLAYOUT; typedef struct { S16 advance; @@ -492,7 +501,7 @@ typedef struct typedef struct _FONTUSAGE { int* chars; char is_reduced; -} FONTUSAGE, * LPFONTUSAGE; +} FONTUSAGE; #define FONT_STYLE_BOLD 1 #define FONT_STYLE_ITALIC 2 @@ -519,7 +528,7 @@ typedef struct _SWFFONT FONTUSAGE * use; -} SWFFONT, * LPSWFFONT; +} SWFFONT; #define ET_HASTEXT 32768 @@ -539,6 +548,11 @@ typedef struct _SWFFONT #define ET_HTML 2 /* MX? */ #define ET_USEOUTLINES 1 +#define ET_ALIGN_LEFT 0 +#define ET_ALIGN_RIGHT 1 +#define ET_ALIGN_CENTER 2 +#define ET_ALIGN_JUSTIFY 3 + typedef struct _EditTextLayout { U8 align; // 0=left, 1=right, 2=center, 3=justify @@ -548,7 +562,7 @@ typedef struct _EditTextLayout U16 leading; } EditTextLayout; -int swf_FontEnumerate(SWF * swf,void (*FontCallback) (U16,U8*)); +int swf_FontEnumerate(SWF * swf,void (*FontCallback) (void*,U16,U8*), void*self); // -> void fontcallback(U16 id,U8 * name); returns number of defined fonts int swf_FontExtract(SWF * swf,int id,SWFFONT ** f); @@ -692,12 +706,14 @@ int swf_ButtonPostProcess(TAG * t,int anz_action); // Set all offsets in DefineB // swfbits.c -typedef int JPEGBITS,* LPJPEGBITS; // cover libjpeg structures +int swf_ImageHasAlpha(RGBA*img, int width, int height); +int swf_ImageGetNumberOfPaletteEntries(RGBA*img, int width, int height, RGBA*palette); -JPEGBITS * swf_SetJPEGBitsStart(TAG * t,int width,int height,int quality); -int swf_SetJPEGBitsLines(JPEGBITS * jpegbits,U8 ** data,int n); -int swf_SetJPEGBitsLine(JPEGBITS * jpegbits,U8 * data); -int swf_SetJPEGBitsFinish(JPEGBITS * jpegbits); +typedef int JPEGBITS; +JPEGBITS * swf_SetJPEGBitsStart(TAG * t,int width,int height,int quality); // deprecated +int swf_SetJPEGBitsLines(JPEGBITS * jpegbits,U8 ** data,int n); // deprecated +int swf_SetJPEGBitsLine(JPEGBITS * jpegbits,U8 * data); // deprecated +int swf_SetJPEGBitsFinish(JPEGBITS * jpegbits); // deprecated void swf_GetJPEGSize(char * fname, int*width, int*height); @@ -705,6 +721,7 @@ int swf_SetJPEGBits(TAG * t,char * fname,int quality); void swf_SetJPEGBits2(TAG * t,U16 width,U16 height,RGBA * bitmap,int quality); int swf_SetJPEGBits3(TAG * tag,U16 width,U16 height,RGBA* bitmap, int quality); RGBA* swf_JPEG2TagToImage(TAG*tag, int*width, int*height); +void swf_RemoveJPEGTables(SWF*swf); #define BYTES_PER_SCANLINE(width) ((width+3)&0xfffffffc) @@ -715,9 +732,13 @@ RGBA* swf_JPEG2TagToImage(TAG*tag, int*width, int*height); int swf_SetLosslessBits(TAG * t,U16 width,U16 height,void * bitmap,U8 bitmap_flags); int swf_SetLosslessBitsIndexed(TAG * t,U16 width,U16 height,U8 * bitmap,RGBA * palette,U16 ncolors); int swf_SetLosslessBitsGrayscale(TAG * t,U16 width,U16 height,U8 * bitmap); +void swf_SetLosslessImage(TAG*tag, RGBA*data, int width, int height); //WARNING: will change tag->id + RGBA* swf_DefineLosslessBitsTagToImage(TAG*tag, int*width, int*height); RGBA* swf_ExtractImage(TAG*tag, int*dwidth, int*dheight); +RGBA* swf_ImageScale(RGBA*data, int width, int height, int newwidth, int newheight); +TAG* swf_AddImage(TAG*tag, int bitid, RGBA*mem, int width, int height, int quality); // swfsound.c void swf_SetSoundStreamHead(TAG*tag, int avgnumsamples); @@ -733,9 +754,14 @@ U8 swf_isPseudoDefiningTag(TAG * t); U8 swf_isAllowedSpriteTag(TAG * t); U8 swf_isImageTag(TAG*tag); U8 swf_isShapeTag(TAG*tag); +U8 swf_isTextTag(TAG*tag); +U8 swf_isFontTag(TAG*tag); +U8 swf_isPlaceTag(TAG*tag); U16 swf_GetDefineID(TAG * t); SRECT swf_GetDefineBBox(TAG * t); +void swf_SetDefineBBox(TAG * t, SRECT r); + void swf_SetDefineID(TAG * t, U16 newid); U16 swf_GetPlaceID(TAG * t); //PLACEOBJECT, PLACEOBJECT2 (sometimes), REMOVEOBJECT int swf_GetDepth(TAG * t); //PLACEOBJECT,PLACEOBJECT2,REMOVEOBJECT,REMOVEOBJECT2,SETTABINDEX @@ -750,6 +776,8 @@ void swf_RelocateDepth(SWF*swf, char*bitmap); // bitmap is 65536 bytes, bitmap[d TAG* swf_Concatenate (TAG*list1,TAG*list2); // warning: both list1 and list2 are invalid after this call. +RGBA swf_GetSWFBackgroundColor(SWF*swf); + // swfcgi.c void swf_uncgi(); // same behaviour as Steven Grimm's uncgi-library @@ -940,6 +968,26 @@ void swf_SetVideoStreamPFrame(TAG*tag, VIDEOSTREAM*s, RGBA*pic, int quant/* 1-31 void swf_SetVideoStreamMover(TAG*tag, VIDEOSTREAM*s, signed char* movex, signed char* movey, void** image, int quant); void swf_VideoStreamClear(VIDEOSTREAM*stream); +// swfrender.c + +typedef struct RENDERBUF +{ + int width; + int height; + int posx,posy; + void*internal; +} RENDERBUF; + +void swf_Render_Init(RENDERBUF*buf, int posx, int posy, int width, int height, int antialize, int multiply); +void swf_Render_SetBackground(RENDERBUF*buf, RGBA*img, int width, int height); +void swf_Render_SetBackgroundColor(RENDERBUF*buf, RGBA color); +RGBA* swf_Render(RENDERBUF*dest); +void swf_RenderShape(RENDERBUF*dest, SHAPE2*shape, MATRIX*m, CXFORM*c, U16 depth,U16 clipdepth); +void swf_RenderSWF(RENDERBUF*buf, SWF*swf); +void swf_Render_AddImage(RENDERBUF*buf, U16 id, RGBA*img, int width, int height); +void swf_Render_ClearCanvas(RENDERBUF*dest); +void swf_Render_Delete(RENDERBUF*dest); + #ifdef __cplusplus } #endif