~ubuntu-branches/ubuntu/lucid/swftools/lucid

« back to all changes in this revision

Viewing changes to lib/rfxswf.h

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2009-04-30 05:22:19 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090430052219-l1n64qofzeq5pej8
Tags: 0.9.0-0ubuntu1
* New upstream release (LP: #369931)
  - patches/01_manpages: edited to match updated version of src/pdf2swf.1 and
    src/wav2swf.1
  - patches/02_faq: edited to match updated version of FAQ
  - patches/04_makefile: edited to delete the patch on lib/Makefile.in and 
    src/Makefile.in (applied upstream)
  - deleted patch 99_configure_for_python2.5_and_2.6 (applied upstream)
  - debian/swftools.doc: deleted installation of TODO and 
    pdf2swf/HOWTO_pdf2swf as they don't exist anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
   Part of the swftools package.
6
6
 
7
7
   Copyright (c) 2000, 2001 Rainer B�hme <rfxswf@reflex-studio.de>
8
 
 
 
8
 
9
9
   This program is free software; you can redistribute it and/or modify
10
10
   it under the terms of the GNU General Public License as published by
11
11
   the Free Software Foundation; either version 2 of the License, or
19
19
   You should have received a copy of the GNU General Public License
20
20
   along with this program; if not, write to the Free Software
21
21
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
22
 
 
 
22
 
23
23
 
24
24
#ifndef __RFX_SWF_INCLUDED__
25
25
#define __RFX_SWF_INCLUDED__
26
26
 
27
 
#ifdef __cplusplus
28
 
extern "C" {
29
 
#endif
30
 
 
31
27
#include <stdio.h>
32
28
#include <stdlib.h>
33
29
#include <math.h>
34
30
#include <string.h>
 
31
#ifndef WIN32
35
32
#include <unistd.h>
 
33
#endif
36
34
#include <fcntl.h>
37
35
#include <ctype.h>
38
36
#include "../config.h"
41
39
#include "./mem.h"
42
40
#include "./types.h"
43
41
 
 
42
#ifdef __cplusplus
 
43
extern "C" {
 
44
#endif
 
45
 
44
46
#define DEBUG_RFXSWF
45
47
#ifdef RFXSWF_DISABLESOUND
46
48
#define NO_MP3
47
49
#endif
48
50
 
49
 
typedef         signed long     SFIXED;
50
 
typedef         signed long     SCOORD;
 
51
typedef signed SFIXED;
 
52
typedef signed SCOORD;
51
53
 
52
 
#define SCOORD_MAX 0x7fffffff
53
 
#define SCOORD_MIN -0x80000000
 
54
#define SCOORD_MAX 0x7fffffffl
 
55
#define SCOORD_MIN -0x80000000l
54
56
 
55
57
// Basic Structures
56
58
 
123
125
 
124
126
  U8            readBit;        // for Bit-Manipulating Functions [read]
125
127
  U8            writeBit;       // [write]
126
 
  
 
128
 
127
129
} TAG;
128
130
 
129
131
#define swf_ResetReadBits(tag)   if (tag->readBit)  { tag->pos++; tag->readBit = 0; }
130
132
#define swf_ResetWriteBits(tag)  if (tag->writeBit) { tag->writeBit = 0; }
131
133
 
132
 
typedef struct _SOUNDINFO 
 
134
typedef struct _SOUNDINFO
133
135
{
134
136
    U8 stop;
135
137
    U8 nomultiple; //continue playing if already started
146
148
    U32* right;
147
149
} SOUNDINFO;
148
150
 
 
151
#define FILEATTRIBUTE_USENETWORK 1
 
152
#define FILEATTRIBUTE_AS3 8
 
153
#define FILEATTRIBUTE_SYMBOLCLASS 16
149
154
typedef struct _SWF
150
155
{ U8            fileVersion;
151
156
  U8            compressed;     // SWF or SWC?
154
159
  U16           frameRate;
155
160
  U16           frameCount;     // valid after load and save
156
161
  TAG *         firstTag;
 
162
  U32           fileAttributes; // for SWFs >= Flash9
157
163
} SWF;
158
164
 
159
165
// Basic Functions
160
166
 
 
167
SWF* swf_OpenSWF(char*filename);
161
168
int  swf_ReadSWF2(reader_t*reader, SWF * swf);   // Reads SWF via callback
162
169
int  swf_ReadSWF(int handle,SWF * swf);     // Reads SWF to memory (malloc'ed), returns length or <0 if fails
163
170
int  swf_WriteSWF2(writer_t*writer, SWF * swf);     // Writes SWF via callback, returns length or <0 if fails
164
171
int  swf_WriteSWF(int handle,SWF * swf);    // Writes SWF to file, returns length or <0 if fails
165
 
int  swf_WriteSWC(int handle, SWF * swf);   // for convenience, equal to swf->compressed=1;swf_WriteSWF(..)
166
172
int  swf_WriteCGI(SWF * swf);               // Outputs SWF with valid CGI header to stdout
167
173
void swf_FreeTags(SWF * swf);               // Frees all malloc'ed memory for swf
168
174
SWF* swf_CopySWF(SWF*swf);
 
175
void swf_ReadABCfile(char*filename, SWF*swf);
169
176
 
170
177
// for streaming:
171
178
int  swf_WriteHeader(int handle,SWF * swf);    // Writes Header of swf to file
188
195
void swf_OptimizeTagOrder(SWF*swf);
189
196
 
190
197
// basic routines:
191
 
    
 
198
 
192
199
TAG * swf_InsertTag(TAG * after,U16 id);    // updates frames, if necessary
193
200
TAG * swf_InsertTagBefore(SWF*swf, TAG * before,U16 id);     // like InsertTag, but insert tag before argument
194
 
int   swf_DeleteTag(TAG * t);
 
201
TAG * swf_DeleteTag(SWF*swf, TAG * t);
195
202
 
196
203
void  swf_ClearTag(TAG * t);                //frees tag data
197
204
void  swf_ResetTag(TAG*tag, U16 id);        //set's tag position and length to 0, without freeing it
198
205
TAG*  swf_CopyTag(TAG*tag, TAG*to_copy);     //stores a copy of another tag into this taglist
199
 
    
 
206
 
200
207
void  swf_SetTagPos(TAG * t,U32 pos);       // resets Bitcount
201
208
U32   swf_GetTagPos(TAG * t);
202
209
 
210
217
U32   swf_GetBits(TAG * t,int nbits);
211
218
S32   swf_GetSBits(TAG * t,int nbits);
212
219
int   swf_SetBits(TAG * t,U32 v,int nbits);
 
220
int   swf_CountUBits(U32 v,int nbits);
 
221
int   swf_CountBits(U32 v,int nbits);
213
222
 
214
223
int   swf_GetBlock(TAG * t,U8 * b,int l);   // resets Bitcount
215
 
int   swf_SetBlock(TAG * t,U8 * b,int l);
 
224
int   swf_SetBlock(TAG * t,const U8 * b,int l);
216
225
 
217
226
U8    swf_GetU8(TAG * t);                   // resets Bitcount
218
227
U16   swf_GetU16(TAG * t);
221
230
void  swf_GetRGB(TAG * t, RGBA * col);
222
231
void  swf_GetRGBA(TAG * t, RGBA * col);
223
232
void  swf_GetGradient(TAG * t, GRADIENT * gradient, char alpha);
 
233
void  swf_SetGradient(TAG * tag, GRADIENT * gradient, char alpha);
224
234
void  swf_FreeGradient(GRADIENT* gradient);
225
235
char* swf_GetString(TAG*t);
226
236
int   swf_SetU8(TAG * t,U8 v);              // resets Bitcount
227
237
int   swf_SetU16(TAG * t,U16 v);
228
238
void  swf_SetS16(TAG * t,int v);
229
239
int   swf_SetU32(TAG * t,U32 v);
230
 
#define swf_SetString(t,s)  swf_SetBlock(t,s,strlen(s)+1)
 
240
void  swf_SetString(TAG*t,const char*s);
 
241
 
 
242
/* abc datatypes */
 
243
U32 swf_GetU30(TAG*tag);
 
244
int swf_SetU30(TAG*tag, U32 u);
 
245
void swf_SetABCU32(TAG*tag, U32 u);
 
246
U32 swf_GetABCU32(TAG*tag);
 
247
void swf_SetABCS32(TAG*tag, S32 v);
 
248
S32 swf_GetABCS32(TAG*tag);
 
249
int    swf_SetU30String(TAG*tag, const char*str, int len);
 
250
double swf_GetD64(TAG*tag);
 
251
int    swf_SetD64(TAG*tag, double v);
 
252
int    swf_GetU24(TAG*tag);
 
253
int    swf_GetS24(TAG*tag);
 
254
int    swf_SetU24(TAG*tag, U32 v);
 
255
int    swf_SetS24(TAG*tag, U32 v);
231
256
 
232
257
//int   swf_GetPoint(TAG * t,SPOINT * p);     // resets Bitcount
233
258
int   swf_GetRect(TAG * t,SRECT * r);
251
276
 
252
277
// helper functions:
253
278
 
 
279
SRECT swf_ClipRect(SRECT border, SRECT r);
254
280
void swf_ExpandRect(SRECT*src, SPOINT add);
255
281
void swf_ExpandRect2(SRECT*src, SRECT*add);
256
282
void swf_ExpandRect3(SRECT*src, SPOINT center, int radius);
270
296
#define ST_PLACEOBJECT          4
271
297
#define ST_REMOVEOBJECT         5
272
298
#define ST_DEFINEBITS           6
273
 
#define ST_DEFINEBITSJPEG       6 
 
299
#define ST_DEFINEBITSJPEG       6
274
300
#define ST_DEFINEBUTTON         7
275
301
#define ST_JPEGTABLES           8
276
302
#define ST_SETBACKGROUNDCOLOR   9
323
349
#define ST_FILEATTRIBUTES       69 /* version 8 (required)- */
324
350
#define ST_PLACEOBJECT3         70 /* version 8 */
325
351
#define ST_IMPORTASSETS2        71 /* version 8 */
 
352
#define ST_RAWABC               72 /* version 9, used by flex */
326
353
#define ST_DEFINEFONTALIGNZONES 73 /* version 8 */
327
354
#define ST_CSMTEXTSETTINGS      74 /* version 8 */
328
355
#define ST_DEFINEFONT3          75 /* version 8 */
 
356
#define ST_SYMBOLCLASS          76 /* version 9 */
329
357
#define ST_METADATA             77 /* version 8 */
330
358
#define ST_DEFINESCALINGGRID    78 /* version 8 */
 
359
#define ST_DOABC                82 /* version 9 */
331
360
#define ST_DEFINESHAPE4         83 /* version 8 */
332
361
#define ST_DEFINEMORPHSHAPE2    84 /* version 8 */
 
362
#define ST_SCENEDESCRIPTION     86 /* version 9 */
 
363
#define ST_DEFINEBINARY         87 /* version 9 */
 
364
#define ST_DEFINEFONTNAME       88 /* version 9 */
333
365
 
334
366
/* custom tags- only valid for swftools */
335
367
#define ST_REFLEX              777 /* to identify generator software */
353
385
typedef struct _FILLSTYLE
354
386
{ U8        type;
355
387
  RGBA      color;
356
 
  MATRIX    m; 
 
388
  MATRIX    m;
357
389
  U16       id_bitmap;
358
390
  GRADIENT  gradient;
359
391
} FILLSTYLE;
360
 
     
 
392
 
361
393
typedef struct _SHAPE           // NEVER access a Shape-Struct directly !
362
 
{                 
 
394
{
363
395
  struct
364
396
  { LINESTYLE * data;
365
397
    U16         n;
366
398
  } linestyle;
367
 
                  
368
 
  struct                    
 
399
 
 
400
  struct
369
401
  { FILLSTYLE * data;
370
402
    U16         n;
371
403
  } fillstyle;
372
 
 
 
404
 
373
405
  struct
374
406
  { U16         fill;
375
407
    U16         line;
392
424
    SRECT* bbox; // may be NULL
393
425
} SHAPE2;
394
426
 
 
427
enum SHAPELINETYPE {moveTo, lineTo, splineTo};
395
428
typedef struct _SHAPELINE
396
429
{
397
 
    enum {moveTo, lineTo, splineTo} type;
 
430
    enum SHAPELINETYPE type;
398
431
    SCOORD x,y;
399
432
    SCOORD sx,sy; //only if type==splineTo
400
433
    int fillstyle0;
431
464
int   swf_ShapeSetCurve(TAG * t,SHAPE * s,S32 x,S32 y,S32 ax,S32 ay);
432
465
int   swf_ShapeSetCircle(TAG * t,SHAPE * s,S32 x,S32 y,S32 rx,S32 ry);
433
466
int   swf_ShapeSetEnd(TAG * t);
 
467
int   swf_SetShapeStyleCount(TAG * t,U16 n);
 
468
int   swf_SetFillStyle(TAG * t,FILLSTYLE * f);
 
469
int   swf_SetLineStyle(TAG * t,LINESTYLE * l);
 
470
 
434
471
 
435
472
void  swf_ShapeSetBitmapRect(TAG * t, U16 gfxid, int width, int height);
436
473
 
446
483
void swf_ParseDefineShape(TAG*tag, SHAPE2*shape);
447
484
void swf_SetShape2(TAG*tag, SHAPE2*shape2);
448
485
 
449
 
void swf_RecodeShapeData(U8*data, int bitlen, int in_bits_fill, int in_bits_line, 
 
486
void swf_RecodeShapeData(U8*data, int bitlen, int in_bits_fill, int in_bits_line,
450
487
                         U8**destdata, U32*destbitlen, int out_bits_fill, int out_bits_line);
451
488
 
452
489
// swfdraw.c
486
523
{ int* chars;
487
524
  char is_reduced;
488
525
  int used_glyphs;
 
526
  int glyphs_specified;
489
527
} FONTUSAGE;
490
528
 
491
529
#define FONT_STYLE_BOLD 1
492
530
#define FONT_STYLE_ITALIC 2
493
531
#define FONT_ENCODING_UNICODE 1
494
 
#define FONT_ENCODING_ANSI 2 
 
532
#define FONT_ENCODING_ANSI 2
495
533
#define FONT_ENCODING_SHIFTJIS 4
496
534
 
497
535
typedef struct _SWFFONT
499
537
  U8            version; // 0 = not set, 1 = definefont, 2 = definefont2
500
538
  U8 *          name;
501
539
  SWFLAYOUT *   layout;
502
 
  U16           numchars;
503
 
  U16           maxascii; // highest mapped ascii value
504
 
  
 
540
  int           numchars;
 
541
  int           maxascii; // highest mapped ascii/unicode value
 
542
 
505
543
  U8            style;
506
544
  U8            encoding;
507
545
 
553
591
int swf_FontExtract(SWF * swf,int id,SWFFONT ** f);
554
592
// Fetches all available information from DefineFont, DefineFontInfo, DefineText, ...
555
593
// id = FontID, id=0 -> Extract first Font
 
594
int swf_FontExtract_DefineFont2(int id, SWFFONT * font, TAG * tag);
 
595
int swf_FontExtract_DefineFontInfo(int id, SWFFONT * f, TAG * t);
 
596
int swf_FontExtract_DefineFont(int id, SWFFONT * f, TAG * t);
 
597
int swf_FontExtract_GlyphNames(int id, SWFFONT * f, TAG * tag);
556
598
 
557
599
int swf_FontIsItalic(SWFFONT * f);
558
600
int swf_FontIsBold(SWFFONT * f);
559
601
 
560
602
int swf_FontSetID(SWFFONT * f,U16 id);
561
603
int swf_FontReduce(SWFFONT * f);
 
604
int swf_FontReduce_swfc(SWFFONT * f);
562
605
 
563
606
int swf_FontInitUsage(SWFFONT * f);
564
607
int swf_FontUseGlyph(SWFFONT * f, int glyph);
 
608
int swf_FontUseAll(SWFFONT* f);
 
609
int swf_FontUseUTF8(SWFFONT * f, U8 * s);
565
610
int swf_FontUse(SWFFONT* f,U8 * s);
566
611
 
567
612
int swf_FontSetDefine(TAG * t,SWFFONT * f);
574
619
int swf_ParseDefineText(TAG * t, void(*callback)(void*self, int*chars, int*xpos, int nr, int fontid, int fontsize, int xstart, int ystart, RGBA* color), void*self);
575
620
 
576
621
void swf_WriteFont(SWFFONT* font, char* filename);
577
 
SWFFONT* swf_ReadFont(char* filename);
 
622
SWFFONT* swf_ReadFont(const char* filename);
578
623
 
579
624
void swf_FontFree(SWFFONT * f);
580
625
 
591
636
void swf_FontPrepareForEditText(SWFFONT * f);
592
637
 
593
638
/* notice: if you set the fontid, make sure you call swf_FontPrepareForEditText() for the font first */
594
 
void swf_SetEditText(TAG*tag, U16 flags, SRECT r, char*text, RGBA*color, 
595
 
        int maxlength, U16 font, U16 height, EditTextLayout*layout, char*variable);
596
 
 
597
 
SRECT swf_SetDefineText(TAG*tag, SWFFONT*font, RGBA*rgb, char*text, int scale);
598
 
 
599
 
void swf_DrawText(drawer_t*draw, SWFFONT*font, int size, char*text);
 
639
void swf_SetEditText(TAG*tag, U16 flags, SRECT r, const char*text, RGBA*color,
 
640
        int maxlength, U16 font, U16 height, EditTextLayout*layout, const char*variable);
 
641
 
 
642
SRECT swf_SetDefineText(TAG*tag, SWFFONT*font, RGBA*rgb, const char*text, int scale);
 
643
 
 
644
void swf_DrawText(drawer_t*draw, SWFFONT*font, int size, const char*text);
600
645
 
601
646
// swffont.c
602
647
 
603
 
SWFFONT* swf_LoadTrueTypeFont(char*filename);
604
 
SWFFONT* swf_LoadT1Font(char*filename);
605
 
SWFFONT* swf_LoadFont(char*filename);
 
648
SWFFONT* swf_LoadTrueTypeFont(const char*filename);
 
649
SWFFONT* swf_LoadT1Font(const char*filename);
 
650
SWFFONT* swf_LoadFont(const char*filename);
606
651
 
607
652
void swf_SetLoadFontParameters(int scale, int skip_unused, int full_unicode);
608
653
 
610
655
 
611
656
void swf_DumpHeader(FILE * f,SWF * swf);
612
657
void swf_DumpMatrix(FILE * f,MATRIX * m);
613
 
void swf_DumpTag(FILE * f,TAG * t); 
 
658
void swf_DumpTag(FILE * f,TAG * t);
614
659
void swf_DumpSWF(FILE * f,SWF*swf);
615
660
void swf_DumpGradient(FILE* f, GRADIENT*gradient);
616
661
char* swf_TagGetName(TAG*tag);
617
662
void swf_DumpFont(SWFFONT * font);
618
663
 
619
 
// swfbutton.c
620
 
 
621
 
// Button States
622
 
 
623
 
#define BS_HIT          0x08
624
 
#define BS_DOWN         0x04
625
 
#define BS_OVER         0x02
626
 
#define BS_UP           0x01
627
 
 
628
 
// Button Conditions
629
 
 
630
 
/* missing: IDLE_OUTDOWN 
631
 
            OUTDOWN_OVERUP
632
 
            OVERUP_OUTDOWN
633
 
*/
634
 
#define BC_OVERDOWN_IDLE        0x0100
635
 
#define BC_IDLE_OVERDOWN        0x0080
636
 
#define BC_OUTDOWN_IDLE         0x0040
637
 
#define BC_OUTDOWN_OVERDOWN     0x0020
638
 
#define BC_OVERDOWN_OUTDOWN     0x0010
639
 
#define BC_OVERDOWN_OVERUP      0x0008
640
 
#define BC_OVERUP_OVERDOWN      0x0004
641
 
#define BC_OVERUP_IDLE          0x0002
642
 
#define BC_IDLE_OVERUP          0x0001
643
 
 
644
 
#define BC_KEY(c) (c<<9)
645
 
 
646
 
#define BC_CURSORLEFT           0x0200
647
 
#define BC_CURSORRIGHT          0x0400
648
 
#define BC_POS1                 0x0600
649
 
#define BC_END                  0x0800
650
 
#define BC_INSERT               0x0a00
651
 
#define BC_DELETE               0x0c00
652
 
#define BC_CLEAR                0x0e00
653
 
#define BC_BACKSPACE            0x1000
654
 
#define BC_ENTER                0x1a00
655
 
#define BC_CURSORUP             0x1c00
656
 
#define BC_CURSORDOWN           0x1e00
657
 
#define BC_PAGEUP               0x2000
658
 
#define BC_PAGEDOWN             0x2200
659
 
#define BC_TAB                  0x2400
660
 
#define BC_ESCAPE               0x3600
661
 
#define BC_SPACE                0x4000
662
 
 
663
 
/* these are probably only valid with linux:
664
 
   Ctrl-A        0x0200
665
 
   Ctrl-X        0x3000
666
 
   Ctrl-Y        0x3200
667
 
   Ctrl-Z        0x3400
668
 
   Escape/Ctrl-[ 0x3600
669
 
   Ctrl-\        0x3800
670
 
   Ctrl-]        0x3a00
671
 
   Ctrl-^        0x3c00
672
 
   Ctrl-/        0x3e00
673
 
   */
674
 
 
675
 
/* everything above 0x4000 is standard ascii:
676
 
   0x4000 ' ' 0x4200 '!' 0x4600 '#' 0x4800 '$' 0x4a00 '%' 0x4c00 '&' ...
677
 
   0x6000 '0' ... 0x7200 '9' 
678
 
   0x8000 '@' 
679
 
   0x8200 'A' ...  0xb400 'Z' 
680
 
   ...
681
 
   0xfc00 '~'
682
 
 */
683
 
 
684
 
// Button Flag
685
 
 
686
 
#define BF_TRACKMENU            0x01
687
 
 
688
 
int swf_ButtonSetRecord(TAG * t,U8 state,U16 id,U16 layer,MATRIX * m,CXFORM * cx);
689
 
int swf_ButtonSetCondition(TAG * t,U16 condition); // for DefineButton2
690
 
int swf_ButtonSetFlags(TAG * t,U8 flags);  // necessary for DefineButton2
691
 
int swf_ButtonPostProcess(TAG * t,int anz_action); // Set all offsets in DefineButton2-Tags (how many conditions to process)
692
 
 
693
664
// swfbits.c
694
665
 
695
666
int swf_ImageHasAlpha(RGBA*img, int width, int height);
701
672
int swf_SetJPEGBitsLine(JPEGBITS * jpegbits,U8 * data); // deprecated
702
673
int swf_SetJPEGBitsFinish(JPEGBITS * jpegbits); // deprecated
703
674
 
704
 
void swf_GetJPEGSize(char * fname, int*width, int*height);
 
675
void swf_GetJPEGSize(const char * fname, int*width, int*height);
705
676
 
706
 
int swf_SetJPEGBits(TAG * t,char * fname,int quality);
 
677
int swf_SetJPEGBits(TAG * t,const char * fname,int quality);
707
678
void swf_SetJPEGBits2(TAG * t,U16 width,U16 height,RGBA * bitmap,int quality);
708
679
int swf_SetJPEGBits3(TAG * tag,U16 width,U16 height,RGBA* bitmap, int quality);
709
680
RGBA* swf_JPEG2TagToImage(TAG*tag, int*width, int*height);
763
734
                    int x0,int y0,int x1,int y1,int x2,int y2);
764
735
int swf_GetNumUsedIDs(TAG * t);
765
736
void swf_GetUsedIDs(TAG * t, int * positions);
766
 
void swf_Relocate(SWF*swf, char*bitmap); // bitmap is 65536 bytes, bitmap[a]==0 means id a is free
 
737
char swf_Relocate(SWF*swf, char*bitmap); // bitmap is 65536 bytes, bitmap[a]==0 means id a is free
767
738
void swf_RelocateDepth(SWF*swf, char*bitmap); // bitmap is 65536 bytes, bitmap[d]==0 means depth d is free
768
739
 
769
740
TAG* swf_Concatenate (TAG*list1,TAG*list2); // warning: both list1 and list2 are invalid after this call.
774
745
 
775
746
void swf_uncgi();  // same behaviour as Steven Grimm's uncgi-library
776
747
 
 
748
// as3/abc.c
 
749
void*swf_ReadABC(TAG*tag);
 
750
void*swf_DumpABC(FILE*fo, void*code, char*prefix);
 
751
void swf_WriteABC(TAG*tag, void*code);
 
752
void swf_FreeABC(void*code);
 
753
void swf_AddButtonLinks(SWF*swf, char stop_each_frame, char events);
 
754
TAG*swf_AddAS3FontDefine(TAG*tag, U16 id, char*fontname);
 
755
#include "as3/compiler.h"
 
756
#include "as3/import.h"
 
757
 
777
758
// swfaction.c
778
759
 
779
 
typedef struct _ActionTAG 
 
760
typedef struct _ActionTAG
780
761
{ U8            op;
781
762
  U16           len;
782
763
  U8 *          data;
804
785
// using action/actioncompiler.h:
805
786
ActionTAG* swf_ActionCompile(const char* source, int version);
806
787
 
 
788
#define ACTION__GOTOFRAME      0x81
 
789
#define ACTION__GETURL         0x83
807
790
ActionTAG* action_End(ActionTAG*atag);
808
791
ActionTAG* action_NextFrame(ActionTAG*atag);
809
792
ActionTAG* action_PreviousFrame(ActionTAG*atag);
878
861
ActionTAG* action_BitRShift(ActionTAG*atag);
879
862
ActionTAG* action_BitURShift(ActionTAG*atag);
880
863
ActionTAG* action_GotoFrame(ActionTAG*atag, U16 frame);
881
 
ActionTAG* action_GetUrl(ActionTAG*atag, char* url, char* label);
 
864
ActionTAG* action_GetUrl(ActionTAG*atag, const char* url, char* label);
882
865
ActionTAG* action_StoreRegister(ActionTAG*atag, U8 reg);
883
866
ActionTAG* action_Constantpool(ActionTAG*atag, char* constantpool);
884
867
ActionTAG* action_WaitForFrame(ActionTAG*atag, U16 frame, U8 skip);
885
 
ActionTAG* action_SetTarget(ActionTAG*atag, char* target);
 
868
ActionTAG* action_SetTarget(ActionTAG*atag, const char* target);
886
869
ActionTAG* action_GotoLabel(ActionTAG*atag, char* label);
887
870
ActionTAG* action_WaitForFrame2(ActionTAG*atag, U8 skip);
888
871
ActionTAG* action_With(ActionTAG*atag, char*object);
889
 
ActionTAG* action_PushString(ActionTAG*atag, char*str);
 
872
ActionTAG* action_PushString(ActionTAG*atag, const char*str);
890
873
ActionTAG* action_PushFloat(ActionTAG*atag, float f);
891
874
ActionTAG* action_PushNULL(ActionTAG*atag);
892
875
ActionTAG* action_PushRegister(ActionTAG*atag, U8 reg);
909
892
 
910
893
extern char*blendModeNames[];
911
894
 
912
 
int swf_ObjectPlace(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name);
913
 
int swf_ObjectPlaceClip(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name, U16 clipaction);
914
 
int swf_ObjectPlaceBlend(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name, U8 blendmode);
 
895
int swf_ObjectPlace(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,const U8 * name);
 
896
int swf_ObjectPlaceClip(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,const U8 * name, U16 clipaction);
 
897
int swf_ObjectPlaceBlend(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,const U8 * name, U8 blendmode);
915
898
int swf_ObjectMove(TAG * t,U16 depth,MATRIX * m,CXFORM * cx);
916
899
 
 
900
#define PF_MOVE         0x01
 
901
#define PF_CHAR         0x02
 
902
#define PF_MATRIX       0x04
 
903
#define PF_CXFORM       0x08
 
904
#define PF_RATIO        0x10
 
905
#define PF_NAME         0x20
 
906
#define PF_CLIPDEPTH    0x40
 
907
#define PF_ACTIONEVENT  0x80
 
908
 
 
909
#define PF2_FILTERS      0x01
 
910
#define PF2_BLENDMODE    0x02
 
911
#define PF2_ASBITMAP     0x04
 
912
//...
 
913
 
917
914
typedef struct _SWFPLACEOBJECT {
918
915
    U16 depth;
919
916
    U16 id; // may be 0
965
962
void swf_SetVideoStreamMover(TAG*tag, VIDEOSTREAM*s, signed char* movex, signed char* movey, void** image, int quant);
966
963
void swf_VideoStreamClear(VIDEOSTREAM*stream);
967
964
 
 
965
// swfbutton.c
 
966
 
 
967
// Button States
 
968
 
 
969
#define BS_HIT          0x08
 
970
#define BS_DOWN         0x04
 
971
#define BS_OVER         0x02
 
972
#define BS_UP           0x01
 
973
 
 
974
// Button Conditions
 
975
 
 
976
/* missing: IDLE_OUTDOWN
 
977
            OUTDOWN_OVERUP
 
978
            OVERUP_OUTDOWN
 
979
*/
 
980
#define BC_OVERDOWN_IDLE        0x0100
 
981
#define BC_IDLE_OVERDOWN        0x0080
 
982
#define BC_OUTDOWN_IDLE         0x0040
 
983
#define BC_OUTDOWN_OVERDOWN     0x0020
 
984
#define BC_OVERDOWN_OUTDOWN     0x0010
 
985
#define BC_OVERDOWN_OVERUP      0x0008
 
986
#define BC_OVERUP_OVERDOWN      0x0004
 
987
#define BC_OVERUP_IDLE          0x0002
 
988
#define BC_IDLE_OVERUP          0x0001
 
989
 
 
990
#define BC_KEY(c) (c<<9)
 
991
 
 
992
#define BC_CURSORLEFT           0x0200
 
993
#define BC_CURSORRIGHT          0x0400
 
994
#define BC_POS1                 0x0600
 
995
#define BC_END                  0x0800
 
996
#define BC_INSERT               0x0a00
 
997
#define BC_DELETE               0x0c00
 
998
#define BC_CLEAR                0x0e00
 
999
#define BC_BACKSPACE            0x1000
 
1000
#define BC_ENTER                0x1a00
 
1001
#define BC_CURSORUP             0x1c00
 
1002
#define BC_CURSORDOWN           0x1e00
 
1003
#define BC_PAGEUP               0x2000
 
1004
#define BC_PAGEDOWN             0x2200
 
1005
#define BC_TAB                  0x2400
 
1006
#define BC_ESCAPE               0x3600
 
1007
#define BC_SPACE                0x4000
 
1008
 
 
1009
/* these are probably only valid with linux:
 
1010
   Ctrl-A        0x0200
 
1011
   Ctrl-X        0x3000
 
1012
   Ctrl-Y        0x3200
 
1013
   Ctrl-Z        0x3400
 
1014
   Escape/Ctrl-[ 0x3600
 
1015
   Ctrl-\        0x3800
 
1016
   Ctrl-]        0x3a00
 
1017
   Ctrl-^        0x3c00
 
1018
   Ctrl-/        0x3e00
 
1019
   */
 
1020
 
 
1021
/* everything above 0x4000 is standard ascii:
 
1022
   0x4000 ' ' 0x4200 '!' 0x4600 '#' 0x4800 '$' 0x4a00 '%' 0x4c00 '&' ...
 
1023
   0x6000 '0' ... 0x7200 '9'
 
1024
   0x8000 '@'
 
1025
   0x8200 'A' ...  0xb400 'Z'
 
1026
   ...
 
1027
   0xfc00 '~'
 
1028
 */
 
1029
 
 
1030
// Button Flag
 
1031
 
 
1032
#define BF_TRACKMENU            0x01
 
1033
 
 
1034
int swf_ButtonSetRecord(TAG * t,U8 state,U16 id,U16 layer,MATRIX * m,CXFORM * cx);
 
1035
int swf_ButtonSetCondition(TAG * t,U16 condition); // for DefineButton2
 
1036
int swf_ButtonSetFlags(TAG * t,U8 flags);  // necessary for DefineButton2
 
1037
int swf_ButtonPostProcess(TAG * t,int anz_action); // Set all offsets in DefineButton2-Tags (how many conditions to process)
 
1038
ActionTAG* swf_ButtonGetAction(TAG*t);
 
1039
 
968
1040
// swfrender.c
969
1041
 
970
 
typedef struct RENDERBUF 
 
1042
typedef struct RENDERBUF
971
1043
{
972
1044
    int width;
973
1045
    int height;
981
1053
RGBA* swf_Render(RENDERBUF*dest);
982
1054
void swf_RenderShape(RENDERBUF*dest, SHAPE2*shape, MATRIX*m, CXFORM*c, U16 depth,U16 clipdepth);
983
1055
void swf_RenderSWF(RENDERBUF*buf, SWF*swf);
984
 
void swf_Render_AddImage(RENDERBUF*buf, U16 id, RGBA*img, int width, int height);
 
1056
void swf_Render_AddImage(RENDERBUF*buf, U16 id, RGBA*img, int width, int height); /* img is non-premultiplied */
985
1057
void swf_Render_ClearCanvas(RENDERBUF*dest);
986
1058
void swf_Render_Delete(RENDERBUF*dest);
987
1059
 
995
1067
#define FILTERTYPE_CONVOLUTION 5
996
1068
#define FILTERTYPE_COLORMATRIX 6
997
1069
#define FILTERTYPE_GRADIENTBEVEL 7
998
 
        
 
1070
 
999
1071
extern char*filtername[];
1000
1072
 
1001
1073
typedef struct _FILTER_GRADIENTGLOW {
1050
1122
    int passes;
1051
1123
} FILTER_BLUR;
1052
1124
 
 
1125
typedef struct _FILTER_GLOW {
 
1126
    U8 type;
 
1127
    RGBA rgba;
 
1128
    double blurx;
 
1129
    double blury;
 
1130
    double strength;
 
1131
    int passes;
 
1132
    char innerglow;
 
1133
    char knockout;
 
1134
    char composite;
 
1135
} FILTER_GLOW;
 
1136
 
1053
1137
void swf_SetFilter(TAG*tag, FILTER*f);
1054
1138
FILTER*swf_GetFilter(TAG*tag);
1055
1139
FILTER*swf_NewFilter(U8 type);
 
1140
void swf_DeleteFilter(FILTER*f);
1056
1141
 
1057
1142
#ifdef __cplusplus
1058
1143
}
1059
1144
#endif
1060
1145
 
1061
1146
#endif
1062