1 2 %module mingc 3 %include typemaps.i 4 %include cpointer.i 5 %include carrays.i 6 7 %{ 8 #include "ming.h" 9 error(char * msg)10 void error( char *msg ) {}; 11 12 %} 13 14 %typemap(python,in) FILE * { 15 if (!PyFile_Check($input)) { 16 PyErr_SetString(PyExc_TypeError, "Need a file!"); 17 return NULL; 18 } 19 $1 = PyFile_AsFile($input); 20 } 21 22 %typemap(python,in) char * { 23 if (!PyString_Check($input)) { 24 PyErr_SetString(PyExc_TypeError, "not a string"); 25 return NULL; 26 } 27 $1 = PyString_AsString($input); 28 } 29 30 typedef unsigned char byte; 31 32 %typemap(python,in) byte * { 33 if (!PyString_Check($input)) { 34 PyErr_SetString(PyExc_TypeError, "not a string"); 35 return NULL; 36 } 37 $1 = PyString_AsString($input); 38 } 39 40 %typemap(ruby,in) int * { 41 if (NIL_P($input)) { 42 $1 = 0; 43 } else { 44 Check_Type($input, T_ARRAY); 45 $1 = (int *)RARRAY($input)->ptr; 46 } 47 } 48 49 %pointer_functions(int, intp); 50 %pointer_functions(float, floatp); 51 %array_class(float, floatArray); 52 53 int Ming_init(void); 54 void Ming_cleanup(void); 55 void Ming_collectGarbage(void); 56 void Ming_useConstants(int flag); 57 58 /* sets the threshold error for drawing cubic beziers. Lower is more 59 accurate, hence larger file size. */ 60 void Ming_setCubicThreshold(int num); 61 62 /* sets the overall scale, default is 20 */ 63 void Ming_setScale(float scale); 64 float Ming_getScale(void); 65 66 /* set the version number to use */ 67 void Ming_useSWFVersion(int version); 68 69 typedef void *SWFMovie, *SWFBlock, *SWFSound, *SWFDisplayItem, *SWFFill, 70 *SWFShape, *SWFAction, *SWFGradient, *SWFButton, *SWFButtonRecord, 71 *SWFBitmap, *SWFMovieClip, *SWFCharacter, *SWFMatrix, *SWFMorph, 72 *SWFFont, *SWFText, *SWFTextField, *SWFVideoStream, *SWFBrowserFont, 73 *SWFPrebuiltClip, *SWFBinaryData, *SWFInitAction, *SWFFontCharacter, 74 *SWFSoundStream, *SWFFilter, *SWFFontCollection; 75 76 /* 77 * Set output compression level. 78 * Return previous value. 79 */ 80 int Ming_setSWFCompression(int level); 81 82 /* a generic output method. specific instances dump output to file, 83 send to stdout, etc. */ 84 typedef void (*SWFByteOutputMethod)(byte b, void *data); 85 86 87 /***** SWFBlock *****/ 88 89 90 /***** SWFMatrix *****/ 91 92 float SWFMatrix_getScaleX(SWFMatrix m); 93 float SWFMatrix_getRotate0(SWFMatrix m); 94 float SWFMatrix_getRotate1(SWFMatrix m); 95 float SWFMatrix_getScaleY(SWFMatrix m); 96 int SWFMatrix_getTranslateX(SWFMatrix m); 97 int SWFMatrix_getTranslateY(SWFMatrix m); 98 99 100 /***** SWFInput *****/ 101 102 /* A generic input object. Wraps files, buffers and streams; replaces 103 standard file funcs */ 104 105 SWFInput newSWFInput_file(FILE *f); 106 SWFInput newSWFInput_stream(FILE *f); 107 SWFInput newSWFInput_buffer(unsigned char *buffer, int length); 108 SWFInput newSWFInput_allocedBuffer(unsigned char *buffer, int length); 109 void destroySWFInput(SWFInput input); 110 111 int SWFInput_length(SWFInput input); 112 void SWFInput_rewind(SWFInput input); 113 int SWFInput_tell(SWFInput input); 114 void SWFInput_seek(SWFInput input, long offset, int whence); 115 int SWFInput_eof(SWFInput input); 116 117 118 /***** SWFCharacter *****/ 119 120 /* a character is any sort of asset that's referenced later- 121 SWFBitmap, SWFShape, SWFMorph, SWFSound, SWFSprite are all SWFCharacters */ 122 123 float SWFCharacter_getWidth(SWFCharacter character); 124 float SWFCharacter_getHeight(SWFCharacter character); 125 126 127 /***** SWFBitmap *****/ 128 129 SWFBitmap newSWFBitmap_fromInput(SWFInput input); 130 void destroySWFBitmap(SWFBitmap bitmap); 131 132 int SWFBitmap_getWidth(SWFBitmap b); 133 int SWFBitmap_getHeight(SWFBitmap b); 134 135 136 /***** SWFDBLBitmap extends SWFBitmap *****/ 137 138 /* create a new DBL (define bits lossless) bitmap from the given file */ 139 SWFDBLBitmap newSWFDBLBitmap(FILE *f); 140 /* create a new DBL bitmap from the given input object */ 141 SWFDBLBitmap newSWFDBLBitmap_fromInput(SWFInput input); 142 143 #if USE_GIF 144 SWFDBLBitmapData newSWFDBLBitmapData_fromGifFile(const char *name); 145 SWFDBLBitmapData newSWFDBLBitmapData_fromGifInput(SWFInput input); 146 #endif 147 #if USE_PNG 148 SWFDBLBitmapData newSWFDBLBitmapData_fromPngFile(const char *name); 149 SWFDBLBitmapData newSWFDBLBitmapData_fromPngInput(SWFInput input); 150 #endif 151 152 153 /***** SWFJpegBitmap extends SWFBitmap *****/ 154 155 SWFJpegBitmap newSWFJpegBitmap(FILE *f); 156 SWFJpegBitmap newSWFJpegBitmap_fromInput(SWFInput input); 157 158 SWFJpegWithAlpha newSWFJpegWithAlpha(FILE *f, FILE *alpha); 159 SWFJpegWithAlpha newSWFJpegWithAlpha_fromInput(SWFInput input, SWFInput alpha); 160 161 162 /***** SWFGradient *****/ 163 164 typedef enum 165 { 166 SWF_GRADIENT_PAD, 167 SWF_GRADIENT_REFLECT, 168 SWF_GRADIENT_REPEAT 169 } GradientSpreadMode; 170 171 typedef enum 172 { 173 SWF_GRADIENT_NORMAL, 174 SWF_GRADIENT_LINEAR 175 } GradientInterpolationMode; 176 177 178 SWFGradient newSWFGradient(void); 179 void destroySWFGradient(SWFGradient gradient); 180 181 void SWFGradient_addEntry(SWFGradient gradient, 182 float ratio, byte r, byte g, byte b, byte a); 183 184 void SWFGradient_setSpreadMode(SWFGradient gradient, GradientSpreadMode mode); 185 void SWFGradient_setInterpolationMode(SWFGradient gradient, GradientInterpolationMode mode); 186 void SWFGradient_setFocalPoint(SWFGradient gradient, float focalPoint); 187 /***** SWFFillStyle - a fill instance on a shape *****/ 188 189 #define SWFFILL_SOLID 0x00 190 #define SWFFILL_GRADIENT 0x10 191 #define SWFFILL_LINEAR_GRADIENT 0x10 192 #define SWFFILL_RADIAL_GRADIENT 0x12 193 #define SWFFILL_BITMAP 0x40 194 #define SWFFILL_TILED_BITMAP 0x40 195 #define SWFFILL_CLIPPED_BITMAP 0x41 196 197 SWFFillStyle newSWFSolidFillStyle(byte r, byte g, byte b, byte a); 198 SWFFillStyle newSWFGradientFillStyle(SWFGradient gradient, byte radial); 199 SWFFillStyle newSWFBitmapFillStyle(SWFCharacter bitmap, byte flags); 200 201 SWFMatrix SWFFillStyle_getMatrix(SWFFillStyle fill); 202 203 204 /***** SWFLineStyle *****/ 205 206 SWFLineStyle newSWFLineStyle(unsigned short width, byte r, byte g, byte b, byte a); 207 208 #define SWF_LINESTYLE_CAP_ROUND (0<<14) 209 #define SWF_LINESTYLE_CAP_NONE (1<<14) 210 #define SWF_LINESTYLE_CAP_SQUARE (2<<14) 211 212 #define SWF_LINESTYLE_JOIN_ROUND (0<<12) 213 #define SWF_LINESTYLE_JOIN_BEVEL (1<<12) 214 #define SWF_LINESTYLE_JOIN_MITER (2<<12) 215 216 #define SWF_LINESTYLE_FLAG_NOHSCALE (1<<10) 217 #define SWF_LINESTYLE_FLAG_NOVSCALE (1<<9) 218 #define SWF_LINESTYLE_FLAG_HINTING (1<<8) 219 220 #define SWF_LINESTYLE_FLAG_NOCLOSE (1<<2) 221 222 #define SWF_LINESTYLE_FLAG_ENDCAP_ROUND (0<<0) 223 #define SWF_LINESTYLE_FLAG_ENDCAP_NONE (1<<0) 224 #define SWF_LINESTYLE_FLAG_ENDCAP_SQUARE (2<<0) 225 226 SWFLineStyle newSWFLineStyle2(unsigned short width, byte r, byte g, byte b, byte a, 227 int flags, float miterLimit); 228 SWFLineStyle newSWFLineStyle2_filled(unsigned short width, 229 SWFFillStyle fill, int flags, 230 float miterLimit); 231 232 233 /***** SWFShape *****/ 234 235 #define SWF_SHAPE3 3 236 #define SWF_SHAPE4 4 237 #define SWF_SHAPE_USESCALINGSTROKES (1<<0) 238 #define SWF_SHAPE_USENONSCALINGSTROKES (1<<1) 239 240 241 SWFShape newSWFShape(void); 242 /* 243 * returns a shape containing the bitmap in a filled rect 244 * flag can be SWFFILL_CLIPPED_BITMAP or SWFFILL_TILED_BITMAP 245 */ 246 SWFShape newSWFShapeFromBitmap(SWFBitmap bitmap, int flag); 247 void destroySWFShape(SWFShape shape); 248 249 void SWFShape_end(SWFShape shape); 250 void SWFShape_useVersion(SWFShape shape, int version); 251 int SWFShape_getVersion(SWFShape shape); 252 void SWFShape_setRenderHintingFlags(SWFShape shape, int flags); 253 254 void SWFShape_movePenTo(SWFShape shape, double x, double y); 255 void SWFShape_movePen(SWFShape shape, double x, double y); 256 257 float SWFShape_getPenX(SWFShape shape); 258 float SWFShape_getPenY(SWFShape shape); 259 void SWFShape_getPen(SWFShape shape, double* penX, double* penY); 260 261 /* x,y relative to shape origin */ 262 void SWFShape_drawLineTo(SWFShape shape, double x, double y); 263 void SWFShape_drawLine(SWFShape shape, double dx, double dy); 264 265 void SWFShape_drawCurveTo(SWFShape shape, double controlx, double controly, double anchorx, double anchory); 266 void SWFShape_drawCurve(SWFShape shape, double controldx, double controldy, double anchordx, double anchordy); 267 268 void SWFShape_hideLine(SWFShape shape); 269 270 SWFFillStyle SWFShape_addSolidFillStyle(SWFShape shape, 271 byte r, byte g, byte b, byte a); 272 SWFFillStyle SWFShape_addGradientFillStyle(SWFShape shape, 273 SWFGradient gradient, byte flags); 274 SWFFillStyle SWFShape_addBitmapFillStyle(SWFShape shape, 275 SWFBitmap bitmap, byte flags); 276 277 void SWFShape_setLeftFillStyle(SWFShape shape, SWFFillStyle fill); 278 void SWFShape_setRightFillStyle(SWFShape shape, SWFFillStyle fill); 279 280 281 /***** SWFMorph *****/ 282 283 SWFMorph newSWFMorphShape(void); 284 void destroySWFMorph(SWFMorph morph); 285 286 SWFShape SWFMorph_getShape1(SWFMorph morph); 287 SWFShape SWFMorph_getShape2(SWFMorph morph); 288 289 290 /***** SWFFont *****/ 291 292 SWFFont newSWFFont_fromFile(const char *filename); 293 294 void destroySWFFont(SWFFont font); 295 296 float SWFFont_getStringWidth(SWFFont font, const char *string); 297 float SWFFont_getUTF8StringWidth(SWFFont font, const char *string); 298 299 /* deprecated? */ 300 float SWFFont_getWideStringWidth(SWFFont font, const unsigned short *string, int len); 301 #define SWFFont_getWidth SWFFont_getStringWidth 302 303 float SWFFont_getAscent(SWFFont font); 304 float SWFFont_getDescent(SWFFont font); 305 float SWFFont_getLeading(SWFFont font); 306 const char* SWFFont_getName(SWFFont font); 307 int SWFFont_getGlyphCount(SWFFont font); 308 309 SWFFontCollection newSWFFontCollection_fromFile(const char *filename); 310 int SWFFontCollection_getFontCount(SWFFontCollection collection); 311 SWFFont SWFFontCollection_getFont(SWFFontCollection collection, int index); 312 void destroySWFFontCollection(SWFFontCollection collection); 313 314 315 /***** SWFText *****/ 316 317 SWFText newSWFText(void); 318 SWFText newSWFText2(void); 319 void destroySWFText(SWFText text); 320 321 void SWFText_setFont(SWFText text, void* font); 322 void SWFText_setHeight(SWFText text, float height); 323 void SWFText_setColor(SWFText text, byte r, byte g, byte b, byte a); 324 325 void SWFText_moveTo(SWFText text, float x, float y); 326 327 void SWFText_addString(SWFText text, const char* string, int* advance); 328 void SWFText_addUTF8String(SWFText text, const char* string, int* advance); 329 void SWFText_addWideString(SWFText text, const unsigned short* string, 330 int strlen, int* advance); 331 332 void SWFText_setSpacing(SWFText text, float spacing); 333 334 float SWFText_getStringWidth(SWFText text, const char* string); 335 float SWFText_getUTF8StringWidth(SWFText text, const char* string); 336 float SWFText_getWideStringWidth(SWFText text, const unsigned short* string); 337 338 /* deprecated? */ 339 #define SWFText_getWidth SWFText_getStringWidth 340 341 float SWFText_getAscent(SWFText text); 342 float SWFText_getDescent(SWFText text); 343 float SWFText_getLeading(SWFText text); 344 345 /* deprecated: */ 346 #define SWFText_setXY(t,x,y) SWFText_moveTo((t),(x),(y)) 347 348 349 /***** SWFBrowserFont *****/ 350 351 SWFBrowserFont newSWFBrowserFont(const char *name); 352 void destroySWFBrowserFont(SWFBrowserFont browserFont); 353 354 355 /***** SWFFontCharacter *****/ 356 357 void SWFFontCharacter_addChars(SWFFontCharacter font, const char *string); 358 void SWFFontCharacter_addUTF8Chars(SWFFontCharacter font, const char *string); 359 360 361 /***** SWFTextField *****/ 362 363 #define SWFTEXTFIELD_ONMASK 0x2005 /* on bits */ 364 #define SWFTEXTFIELD_OFFMASK 0x3BFF /* off bits */ 365 /* Taken from textfield.h: #define SWFTEXTFIELD_OFFMASK 0x7BFF / off bits */ 366 367 #define SWFTEXTFIELD_HASFONT (1<<0) /* font and size given */ 368 #define SWFTEXTFIELD_HASLENGTH (1<<1) 369 #define SWFTEXTFIELD_HASCOLOR (1<<2) 370 #define SWFTEXTFIELD_NOEDIT (1<<3) 371 #define SWFTEXTFIELD_PASSWORD (1<<4) 372 #define SWFTEXTFIELD_MULTILINE (1<<5) 373 #define SWFTEXTFIELD_WORDWRAP (1<<6) 374 #define SWFTEXTFIELD_HASTEXT (1<<7) /* initial text present */ 375 #define SWFTEXTFIELD_USEFONT (1<<8) 376 #define SWFTEXTFIELD_HTML (1<<9) 377 #define SWFTEXTFIELD_DRAWBOX (1<<11) 378 #define SWFTEXTFIELD_NOSELECT (1<<12) 379 #define SWFTEXTFIELD_HASLAYOUT (1<<13) /* align, margin, lspace, indent */ 380 #define SWFTEXTFIELD_AUTOSIZE (1<<14) /* SWF6 */ 381 382 typedef enum 383 { 384 SWFTEXTFIELD_ALIGN_LEFT = 0, 385 SWFTEXTFIELD_ALIGN_RIGHT = 1, 386 SWFTEXTFIELD_ALIGN_CENTER = 2, 387 SWFTEXTFIELD_ALIGN_JUSTIFY = 3 388 } SWFTextFieldAlignment; 389 390 SWFTextField newSWFTextField(void); 391 void destroySWFTextField(SWFTextField textField); 392 393 void SWFTextField_setFont(SWFTextField field, SWFBlock font); 394 void SWFTextField_setBounds(SWFTextField field, float width, float height); 395 void SWFTextField_setFlags(SWFTextField field, int flags); 396 void SWFTextField_setColor(SWFTextField field, byte r, byte g, byte b, byte a); 397 void SWFTextField_setVariableName(SWFTextField field, const char *name); 398 399 void SWFTextField_addString(SWFTextField field, const char *string); 400 void SWFTextField_addUTF8String(SWFTextField field, const char *string); 401 402 void SWFTextField_setHeight(SWFTextField field, float height); 403 void SWFTextField_setFieldHeight(SWFTextField field, float height); 404 void SWFTextField_setLeftMargin(SWFTextField field, float leftMargin); 405 void SWFTextField_setRightMargin(SWFTextField field, float rightMargin); 406 void SWFTextField_setIndentation(SWFTextField field, float indentation); 407 void SWFTextField_setLineSpacing(SWFTextField field, float lineSpacing); 408 void SWFTextField_setPadding(SWFTextField field, float padding); 409 410 void SWFTextField_addChars(SWFTextField field, const char *string); 411 412 /* deprecated? */ 413 /*void SWFTextField_addUTF8Chars(SWFTextField field, const char *string);*/ 414 415 void SWFTextField_setAlignment(SWFTextField field, 416 SWFTextFieldAlignment alignment); 417 void SWFTextField_setLength(SWFTextField field, int length); 418 419 420 /***** SWFSoundStream - only mp3 streaming implemented *****/ 421 422 SWFSoundStream newSWFSoundStream(FILE *file); 423 /* added by David McNab <david@rebirthing.co.nz> */ 424 SWFSoundStream newSWFSoundStreamFromFileno(int fd); 425 SWFSoundStream newSWFSoundStream_fromInput(SWFInput input); 426 void destroySWFSoundStream(SWFSoundStream soundStream); 427 unsigned int SWFSoundStream_getDuration(SWFSoundStream); 428 void SWFSoundStream_setInitialMp3Delay(SWFSoundStream soundStream, int delay); 429 430 /***** SWFSound *****/ 431 432 SWFSound newSWFSound(FILE *file, byte flags); 433 /* added by David McNab to facilitate Python access */ 434 SWFSound newSWFSoundFromFileno(int fd, byte flags); 435 SWFSound newSWFSound_fromInput(SWFInput input, byte flags); 436 SWFSound newSWFSound_fromSoundStream(SWFSoundStream stream); 437 void destroySWFSound(SWFSound sound); 438 void SWFSound_setInitialMp3Delay(SWFSound sound, int delay); 439 440 #define SWF_SOUND_COMPRESSION 0xf0 441 #define SWF_SOUND_NOT_COMPRESSED (0<<4) 442 #define SWF_SOUND_ADPCM_COMPRESSED (1<<4) 443 #define SWF_SOUND_MP3_COMPRESSED (2<<4) 444 #define SWF_SOUND_NOT_COMPRESSED_LE (3<<4) 445 #define SWF_SOUND_NELLY_COMPRESSED (6<<4) 446 447 #define SWF_SOUND_RATE 0x0c 448 #define SWF_SOUND_5KHZ (0<<2) 449 #define SWF_SOUND_11KHZ (1<<2) 450 #define SWF_SOUND_22KHZ (2<<2) 451 #define SWF_SOUND_44KHZ (3<<2) 452 453 #define SWF_SOUND_BITS 0x02 454 #define SWF_SOUND_8BITS (0<<1) 455 #define SWF_SOUND_16BITS (1<<1) 456 457 #define SWF_SOUND_CHANNELS 0x01 458 #define SWF_SOUND_MONO (0<<0) 459 #define SWF_SOUND_STEREO (1<<0) 460 461 462 /***** SWFSoundInstance *****/ 463 464 /* created from SWFMovie[Clip]_startSound, 465 lets you change the parameters of the sound event (loops, etc.) */ 466 467 void SWFSoundInstance_setLoopInPoint(SWFSoundInstance instance, unsigned int point); 468 void SWFSoundInstance_setLoopOutPoint(SWFSoundInstance instance, unsigned int point); 469 void SWFSoundInstance_setLoopCount(SWFSoundInstance instance, int count); 470 void SWFSoundInstance_setNoMultiple(SWFSoundInstance instance); 471 472 473 /***** SWFCXform - Color transform *****/ 474 475 /* create a new color transform with the given parameters */ 476 SWFCXform newSWFCXform(int rAdd, int gAdd, int bAdd, int aAdd, 477 float rMult, float gMult, float bMult, float aMult); 478 /* create a new color transform with the given additive parameters and 479 default multiplicative */ 480 SWFCXform newSWFAddCXform(int rAdd, int gAdd, int bAdd, int aAdd); 481 /* create a new color transform with the given multiplicative parameters 482 and default additive */ 483 SWFCXform newSWFMultCXform(float rMult, float gMult, float bMult, float aMult); 484 void destroySWFCXform(SWFCXform cXform); 485 486 /* set the additive part of the color transform to the given parameters */ 487 void SWFCXform_setColorAdd(SWFCXform cXform, 488 int rAdd, int gAdd, int bAdd, int aAdd); 489 /* set the multiplicative part of the color transform to the given 490 parameters */ 491 void SWFCXform_setColorMult(SWFCXform cXform, 492 float rMult, float gMult, float bMult, float aMult); 493 494 495 /***** SWFAction *****/ 496 SWFAction newSWFAction(const char *script); 497 SWFAction newSWFAction_fromFile(const char *filename); 498 int SWFAction_compile(SWFAction action, int swfVersion, int *length); 499 void destroySWFAction(SWFAction action); 500 byte *SWFAction_getByteCode(SWFAction action, int *length); 501 502 SWFInitAction newSWFInitAction(SWFAction action); 503 /* use with care */ 504 SWFInitAction newSWFInitAction_withId(SWFAction action, int id); 505 506 /***** SWFButton *****/ 507 508 #define SWFBUTTON_HIT (1<<3) 509 #define SWFBUTTON_DOWN (1<<2) 510 #define SWFBUTTON_OVER (1<<1) 511 #define SWFBUTTON_UP (1<<0) 512 513 /* deprecated: */ 514 515 #define SWFBUTTONRECORD_HITSTATE (1<<3) 516 #define SWFBUTTONRECORD_DOWNSTATE (1<<2) 517 #define SWFBUTTONRECORD_OVERSTATE (1<<1) 518 #define SWFBUTTONRECORD_UPSTATE (1<<0) 519 520 521 #define SWFBUTTON_KEYPRESS(c) (((c)&0x7f)<<9) 522 #define SWFBUTTON_ONKEYPRESS(c) (((c)&0x7f)<<9) 523 524 #define SWFBUTTON_OVERDOWNTOIDLE (1<<8) 525 #define SWFBUTTON_IDLETOOVERDOWN (1<<7) 526 #define SWFBUTTON_OUTDOWNTOIDLE (1<<6) 527 #define SWFBUTTON_OUTDOWNTOOVERDOWN (1<<5) 528 #define SWFBUTTON_OVERDOWNTOOUTDOWN (1<<4) 529 #define SWFBUTTON_OVERDOWNTOOVERUP (1<<3) 530 #define SWFBUTTON_OVERUPTOOVERDOWN (1<<2) 531 #define SWFBUTTON_OVERUPTOIDLE (1<<1) 532 #define SWFBUTTON_IDLETOOVERUP (1<<0) 533 534 /* easier to remember: */ 535 #define SWFBUTTON_MOUSEUPOUTSIDE SWFBUTTON_OUTDOWNTOIDLE 536 #define SWFBUTTON_DRAGOVER (SWFBUTTON_OUTDOWNTOOVERDOWN | SWFBUTTON_IDLETOOVERDOWN) 537 #define SWFBUTTON_DRAGOUT (SWFBUTTON_OVERDOWNTOOUTDOWN | SWFBUTTON_OVERDOWNTOIDLE) 538 #define SWFBUTTON_MOUSEUP SWFBUTTON_OVERDOWNTOOVERUP 539 #define SWFBUTTON_MOUSEDOWN SWFBUTTON_OVERUPTOOVERDOWN 540 #define SWFBUTTON_MOUSEOUT SWFBUTTON_OVERUPTOIDLE 541 #define SWFBUTTON_MOUSEOVER SWFBUTTON_IDLETOOVERUP 542 543 SWFButton newSWFButton(void); 544 void destroySWFButton(SWFButton button); 545 SWFButtonRecord SWFButton_addCharacter(SWFButton, SWFCharacter, byte flags); 546 void SWFButton_addAction(SWFButton button, SWFAction action, int flags); 547 SWFSoundInstance SWFButton_addSound(SWFButton button, SWFSound action, byte flags); 548 void SWFButton_setMenu(SWFButton button, int flag); 549 void SWFButton_setScalingGrid(SWFButton b, int x, int y, int w, int h); 550 void SWFButton_removeScalingGrid(SWFButton b); 551 552 /** SWFButton **/ 553 void SWFButtonRecord_setDepth(SWFButtonRecord b, int depth); 554 void SWFButtonRecord_addFilter(SWFButtonRecord b, SWFFilter f); 555 void SWFButtonRecord_setBlendMode(SWFButtonRecord b, int mode); 556 void SWFButtonRecord_move(SWFButtonRecord record, double x, double y); 557 void SWFButtonRecord_moveTo(SWFButtonRecord record, double x, double y); 558 void SWFButtonRecord_rotate(SWFButtonRecord record, double deg); 559 void SWFButtonRecord_rotateTo(SWFButtonRecord record, double deg); 560 void SWFButtonRecord_scale(SWFButtonRecord record, double scaleX, double scaleY); 561 void SWFButtonRecord_scaleTo(SWFButtonRecord record, double scaleX, double scaleY); 562 void SWFButtonRecord_skewX(SWFButtonRecord record, double skewX); 563 void SWFButtonRecord_skewXTo(SWFButtonRecord record, double skewX); 564 void SWFButtonRecord_skewY(SWFButtonRecord record, double skewY); 565 void SWFButtonRecord_skewYTo(SWFButtonRecord record, double skewY); 566 567 /****** SWFVideo ******/ 568 #define SWFVIDEOSTREAM_MODE_AUTO 0 569 #define SWFVIDEOSTREAM_MODE_MANUAL 1 570 571 SWFVideoStream newSWFVideoStream_fromFile(FILE *f); 572 SWFVideoStream newSWFVideoStream_fromInput(SWFInput input); 573 SWFVideoStream newSWFVideoStream(void); 574 void SWFVideoStream_setDimension(SWFVideoStream stream, int width, int height); 575 int SWFVideoStream_getNumFrames(SWFVideoStream stream); 576 int SWFVideoStream_hasAudio(SWFVideoStream stream); 577 int SWFVideoStream_setFrameMode(SWFVideoStream stream, int mode); 578 int SWFVideoStream_nextFrame(SWFVideoStream stream); 579 int SWFVideoStream_seek(SWFVideoStream stream, int frame, int whence); 580 void destroySWFVideoStream(SWFVideoStream stream); 581 582 /***** SWFSprite *****/ 583 584 SWFSprite newSWFSprite(void); 585 void destroySWFSprite(SWFSprite sprite); 586 587 void SWFSprite_addBlock(SWFSprite sprite, SWFBlock block); 588 589 590 /***** SWFPosition *****/ 591 SWFPosition newSWFPosition(SWFMatrix matrix); 592 void destroySWFPosition(SWFPosition position); 593 594 void SWFPosition_skewX(SWFPosition position, double x); 595 void SWFPosition_skewXTo(SWFPosition position, double x); 596 void SWFPosition_skewY(SWFPosition position, double y); 597 void SWFPosition_skewYTo(SWFPosition position, double y); 598 599 void SWFPosition_scaleX(SWFPosition position, double x); 600 void SWFPosition_scaleXTo(SWFPosition position, double x); 601 void SWFPosition_scaleY(SWFPosition position, double y); 602 void SWFPosition_scaleYTo(SWFPosition position, double y); 603 void SWFPosition_scaleXY(SWFPosition position, double x, double y); 604 void SWFPosition_scaleXYTo(SWFPosition position, double x, double y); 605 606 SWFMatrix SWFPosition_getMatrix(SWFPosition p); 607 void SWFPosition_setMatrix(SWFPosition p, double a, double b, double c, double d, 608 double x, double y); 609 610 void SWFPosition_rotate(SWFPosition position, double degrees); 611 void SWFPosition_rotateTo(SWFPosition position, double degrees); 612 613 void SWFPosition_move(SWFPosition position, double x, double y); 614 void SWFPosition_moveTo(SWFPosition position, double x, double y); 615 616 double SWFPosition_getRotation(SWFPosition position); 617 double SWFPosition_getX(SWFPosition position); 618 double SWFPosition_getY(SWFPosition position); 619 620 void SWFPosition_getXY(SWFPosition position, double* outX, double* outY); 621 622 double SWFPosition_getXScale(SWFPosition position); 623 double SWFPosition_getYScale(SWFPosition position); 624 625 void SWFPosition_getXYScale(SWFPosition position, double* outXScale, double* outYScale); 626 627 double SWFPosition_getXSkew(SWFPosition position); 628 double SWFPosition_getYSkew(SWFPosition position); 629 630 void SWFPosition_getXYSkew(SWFPosition position, double* outXSkew, double* outYSkew); 631 632 /***** SWFDisplayItem *****/ 633 SWFCharacter SWFDisplayItem_getCharacter(SWFDisplayItem item); 634 void SWFDisplayItem_endMask(SWFDisplayItem item); 635 636 void SWFDisplayItem_move(SWFDisplayItem item, double x, double y); 637 void SWFDisplayItem_moveTo(SWFDisplayItem item, double x, double y); 638 void SWFDisplayItem_rotate(SWFDisplayItem item, double degrees); 639 void SWFDisplayItem_rotateTo(SWFDisplayItem item, double degrees); 640 void SWFDisplayItem_scale(SWFDisplayItem item, double xScale, double yScale); 641 void SWFDisplayItem_scaleTo(SWFDisplayItem item, double xScale, double yScale); 642 void SWFDisplayItem_skewX(SWFDisplayItem item, double x); 643 void SWFDisplayItem_skewXTo(SWFDisplayItem item, double x); 644 void SWFDisplayItem_skewY(SWFDisplayItem item, double y); 645 void SWFDisplayItem_skewYTo(SWFDisplayItem item, double y); 646 647 void SWFDisplayItem_getPosition(SWFDisplayItem item, double * x, double * y); 648 void SWFDisplayItem_getRotation(SWFDisplayItem item, double * degrees); 649 void SWFDisplayItem_getScale(SWFDisplayItem item, double * xScale, double * yScale); 650 void SWFDisplayItem_getSkew(SWFDisplayItem item, double * xSkew, double * ySkew); 651 652 SWFMatrix SWFDisplayItem_getMatrix(SWFDisplayItem item); 653 void SWFDisplayItem_setMatrix(SWFDisplayItem i, double a, double b, double c, double d, double x, double y); 654 int SWFDisplayItem_getDepth(SWFDisplayItem item); 655 void SWFDisplayItem_setDepth(SWFDisplayItem item, int depth); 656 void SWFDisplayItem_remove(SWFDisplayItem item); 657 void SWFDisplayItem_setName(SWFDisplayItem item, const char *name); 658 void SWFDisplayItem_setMaskLevel(SWFDisplayItem item, int masklevel); 659 void SWFDisplayItem_setRatio(SWFDisplayItem item, float ratio); 660 void SWFDisplayItem_setCXform(SWFDisplayItem item, SWFCXform cXform); 661 void SWFDisplayItem_setColorAdd(SWFDisplayItem item, 662 int r, int g, int b, int a); 663 void SWFDisplayItem_setColorMult(SWFDisplayItem item, 664 float r, float g, float b, float a); 665 666 #define SWFDisplayItem_addColor SWFDisplayItem_setColorAdd 667 #define SWFDisplayItem_multColor SWFDisplayItem_setColorMult 668 669 #define SWFACTION_ONLOAD (1<<0) 670 #define SWFACTION_ENTERFRAME (1<<1) 671 #define SWFACTION_UNLOAD (1<<2) 672 #define SWFACTION_MOUSEMOVE (1<<3) 673 #define SWFACTION_MOUSEDOWN (1<<4) 674 #define SWFACTION_MOUSEUP (1<<5) 675 #define SWFACTION_KEYDOWN (1<<6) 676 #define SWFACTION_KEYUP (1<<7) 677 #define SWFACTION_DATA (1<<8) 678 679 void SWFDisplayItem_addAction(SWFDisplayItem item, SWFAction action, int flags); 680 681 void SWFDisplayItem_cacheAsBitmap(SWFDisplayItem item, int flag); 682 683 enum { 684 SWFBLEND_MODE_NULL, 685 SWFBLEND_MODE_NORMAL, 686 SWFBLEND_MODE_LAYER, 687 SWFBLEND_MODE_MULT, 688 SWFBLEND_MODE_SCREEN, 689 SWFBLEND_MODE_LIGHTEN, 690 SWFBLEND_MODE_DARKEN, 691 SWFBLEND_MODE_DIFF, 692 SWFBLEND_MODE_ADD, 693 SWFBLEND_MODE_SUB, 694 SWFBLEND_MODE_INV, 695 SWFBLEND_MODE_ALPHA, 696 SWFBLEND_MODE_ERASE, 697 SWFBLEND_MODE_OVERLAY, 698 SWFBLEND_MODE_HARDLIGHT 699 }; 700 701 void SWFDisplayItem_setBlendMode(SWFDisplayItem item, int mode); 702 703 704 /***** SWFFill *****/ 705 706 /* adds a position object to manipulate SWFFillStyle's matrix */ 707 708 SWFFill newSWFFill(SWFFillStyle fillstyle); 709 void destroySWFFill(SWFFill fill); 710 SWFFillStyle SWFFill_getFillStyle(SWFFill fill); 711 712 void SWFFill_skewX(SWFFill fill, float x); 713 void SWFFill_skewXTo(SWFFill fill, float x); 714 void SWFFill_skewY(SWFFill fill, float y); 715 void SWFFill_skewYTo(SWFFill fill, float y); 716 717 void SWFFill_scaleX(SWFFill fill, float x); 718 void SWFFill_scaleXTo(SWFFill fill, float x); 719 void SWFFill_scaleY(SWFFill fill, float y); 720 void SWFFill_scaleYTo(SWFFill fill, float y); 721 void SWFFill_scaleXY(SWFFill fill, float x, float y); 722 void SWFFill_scaleXYTo(SWFFill fill, float x, float y); 723 724 /* Deprecated? */ 725 #define SWFFill_scale SWFFill_scaleXY 726 #define SWFFill_scaleTo SWFFill_scaleXYTo 727 728 void SWFFill_rotate(SWFFill fill, float degrees); 729 void SWFFill_rotateTo(SWFFill fill, float degrees); 730 731 void SWFFill_move(SWFFill fill, float x, float y); 732 void SWFFill_moveTo(SWFFill fill, float x, float y); 733 734 void SWFFill_setMatrix(SWFFill fill, float a, float b, 735 float c, float d, float x, float y); 736 737 738 /***** shape_util.h *****/ 739 740 void SWFShape_setLine(SWFShape shape, unsigned short width, 741 byte r, byte g, byte b, byte a); 742 743 void SWFShape_setLine2Filled(SWFShape shape, unsigned short width, 744 SWFFillStyle fill, 745 int flags, float miterLimit); 746 747 void SWFShape_setLine2(SWFShape shape, unsigned short width, 748 byte r, byte g, byte b, byte a, 749 int flags, float miterLimit); 750 751 752 SWFFill SWFShape_addSolidFill(SWFShape shape, byte r, byte g, byte b, byte a); 753 SWFFill SWFShape_addGradientFill(SWFShape shape, SWFGradient gradient, byte flags); 754 SWFFill SWFShape_addBitmapFill(SWFShape shape, SWFBitmap bitmap, byte flags); 755 756 void SWFShape_setLeftFill(SWFShape shape, SWFFill fill); 757 void SWFShape_setRightFill(SWFShape shape, SWFFill fill); 758 759 void SWFShape_drawArc(SWFShape shape, double r, double startAngle, double endAngle); 760 void SWFShape_drawCircle(SWFShape shape, double r); 761 762 /* draw character c from font font into shape shape at size size */ 763 void SWFShape_drawGlyph(SWFShape shape, SWFFont font, unsigned short c); 764 void SWFShape_drawSizedGlyph(SWFShape shape, SWFFont font, unsigned short c, int size); 765 766 /* Deprecated: */ 767 #define SWFShape_drawFontGlyph(s,f,c) SWFShape_drawGlyph(s,f,c) 768 769 /* approximate a cubic bezier with quadratic segments */ 770 /* returns the number of segments used */ 771 int SWFShape_drawCubic(SWFShape shape, double bx, double by, double cx, double cy, double dx, double dy); 772 int SWFShape_drawCubicTo(SWFShape shape, double bx, double by, double cx, double cy, double dx, double dy); 773 void SWFShape_drawCharacterBounds(SWFShape shape, SWFCharacter character); 774 775 776 /***** SWFMovieClip *****/ 777 778 SWFMovieClip newSWFMovieClip(void); 779 void destroySWFMovieClip(SWFMovieClip movieClip); 780 781 void SWFMovieClip_setNumberOfFrames(SWFMovieClip clip, int frames); 782 void SWFMovieClip_nextFrame(SWFMovieClip clip); 783 void SWFMovieClip_labelFrame(SWFMovieClip clip, const char *label); 784 785 SWFDisplayItem SWFMovieClip_add(SWFMovieClip clip, SWFBlock block); 786 void SWFMovieClip_remove(SWFMovieClip clip, SWFDisplayItem item); 787 void SWFMovieClip_setSoundStreamAt(SWFMovieClip clip, SWFSoundStream sound, float rate, float skipSound); 788 void SWFMovieClip_setSoundStream(SWFMovieClip clip, SWFSoundStream sound, float rate); 789 SWFSoundInstance SWFMovieClip_startSound(SWFMovieClip clip, SWFSound sound); 790 void SWFMovieClip_stopSound(SWFMovieClip clip, SWFSound sound); 791 792 /***** SWFPrebuiltClip ****/ 793 void destroySWFPrebuiltClip(SWFPrebuiltClip clip); 794 SWFPrebuiltClip newSWFPrebuiltClip_fromFile(const char *filename); 795 SWFPrebuiltClip newSWFPrebuiltClip_fromInput(SWFInput input); 796 797 /***** SWFBinaryData *****/ 798 799 SWFBinaryData newSWFBinaryData(unsigned char *blob, int length); 800 801 /***** SWFMovie *****/ 802 803 SWFMovie newSWFMovie(void); 804 SWFMovie newSWFMovieWithVersion(int version); 805 void destroySWFMovie(SWFMovie movie); 806 807 void SWFMovie_setRate(SWFMovie movie, float rate); 808 float SWFMovie_getRate(SWFMovie movie); 809 void SWFMovie_setDimension(SWFMovie movie, float x, float y); 810 void SWFMovie_setNumberOfFrames(SWFMovie movie, int frames); 811 812 void SWFMovie_addExport(SWFMovie movie, SWFBlock block, const char *name); 813 814 void SWFMovie_setBackground(SWFMovie movie, byte r, byte g, byte b); 815 816 void SWFMovie_setSoundStream(SWFMovie movie, SWFSoundStream sound); 817 void SWFMovie_setSoundStreamAt(SWFMovie movie, SWFSoundStream stream, float skip); 818 SWFSoundInstance SWFMovie_startSound(SWFMovie movie, SWFSound sound); 819 void SWFMovie_stopSound(SWFMovie movie, SWFSound sound); 820 821 SWFDisplayItem SWFMovie_add(SWFMovie movie, SWFBlock block); 822 void SWFMovie_remove(SWFMovie movie, SWFDisplayItem item); 823 824 void SWFMovie_nextFrame(SWFMovie movie); 825 void SWFMovie_labelFrame(SWFMovie movie, const char *label); 826 827 int SWFMovie_output(SWFMovie movie, SWFByteOutputMethod method, void *data); 828 int SWFMovie_save(SWFMovie movie, const char *filename); 829 830 void SWFMovie_protect(SWFMovie movie, const char *password); 831 832 void SWFMovie_setNetworkAccess(SWFMovie movie, int flag); 833 void SWFMovie_addMetadata(SWFMovie movie, const char *xml); 834 void SWFMovie_setScriptLimits(SWFMovie movie, int maxRecursion, int timeout); 835 void SWFMovie_setTabIndex(SWFMovie movie, int depth, int i); 836 837 SWFFontCharacter SWFMovie_importFont(SWFMovie movie, const char *filename, const char *name); 838 SWFFontCharacter SWFMovie_addFont(SWFMovie movie, SWFFont font); 839 840 SWFCharacter SWFMovie_importCharacter(SWFMovie movie, const char *filename, const char *name); 841 void SWFMovie_assignSymbol(SWFMovie m, SWFCharacter character, const char *name); 842 void SWFMovie_defineScene(SWFMovie m, unsigned int offset, const char *name); 843 void SWFMovie_namedAnchor(SWFMovie movie, const char *label); 844 void SWFMovie_writeExports(SWFMovie movie); 845 846 /***** SWFFilter ***********/ 847 848 #define SWFFILTER_MODE_INNER (1<<7) 849 #define SWFFILTER_MODE_KO (1<<6) 850 #define SWFFILTER_MODE_COMPOSITE (1<<5) 851 #define SWFFILTER_MODE_ONTOP (1<<4) 852 853 #define SWFFILTER_FLAG_CLAMP (1<<1) 854 #define SWFFILTER_FLAG_PRESERVE_ALPHA (1<<0) 855 856 typedef enum 857 { 858 SWFFILTER_TYPE_DROPSHADOW, 859 SWFFILTER_TYPE_BLUR, 860 SWFFILTER_TYPE_GLOW, 861 SWFFILTER_TYPE_BEVEL, 862 SWFFILTER_TYPE_GRADIENTGLOW, 863 SWFFILTER_TYPE_CONVOLUTION, 864 SWFFILTER_TYPE_COLORMATRIX, 865 SWFFILTER_TYPE_GRADIENTBEVEL 866 } SWFFilterFmt; 867 868 typedef struct SWFColor { 869 unsigned char red; 870 unsigned char green; 871 unsigned char blue; 872 unsigned char alpha; 873 } SWFColor; 874 875 typedef struct Shadow_s *SWFShadow; 876 SWFShadow newSWFShadow(float angle, float distance, float strength); 877 void destroySWFShadow(SWFShadow s); 878 879 typedef struct Blur_s *SWFBlur; 880 SWFBlur newSWFBlur(float blurX, float blurY, int passes); 881 void destroySWFBlur(SWFBlur b); 882 883 typedef struct FilterMatrix_s *SWFFilterMatrix; 884 SWFFilterMatrix newSWFFilterMatrix(int cols, int rows, float *vals); 885 void destroySWFFilterMatrix(SWFFilterMatrix m); 886 887 void destroySWFFilter(SWFFilter filter); 888 SWFFilter newColorMatrixFilter(SWFFilterMatrix matrix); 889 SWFFilter newConvolutionFilter(SWFFilterMatrix matrix, float divisor, 890 float bias, SWFColor color, int flags); 891 892 SWFFilter newGradientBevelFilter(SWFGradient gradient, SWFBlur blur, 893 SWFShadow shadow, int flags); 894 895 SWFFilter newGradientGlowFilter(SWFGradient gradient, SWFBlur blur, 896 SWFShadow shadow, int flags); 897 898 SWFFilter newBevelFilter(SWFColor shadowColor, SWFColor highlightColor, 899 SWFBlur blur, SWFShadow shadow, int flags); 900 901 SWFFilter newGlowFilter(SWFColor color, SWFBlur blur, 902 float strength, int flags); 903 904 SWFFilter newBlurFilter(SWFBlur blur); 905 SWFFilter newDropShadowFilter(SWFColor color, SWFBlur blur, 906 SWFShadow shadow, int flags); 907 void SWFDisplayItem_addFilter(SWFDisplayItem item, SWFFilter filter); 908 909 910