2
* This file is part of SwfLib
3
* Copyright (c)2004 Nicolas Cannasse
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
type action_count = int
43
| GradientRGB of ((int * rgb) list * int)
44
| GradientRGBA of ((int * rgba) list * int)
69
scale : matrix_part option;
70
rotate : matrix_part option;
74
type color_transform_alpha = {
76
cxa_add : rgba option;
77
cxa_mult : rgba option;
80
type function_decl = {
83
mutable f_codelen : action_count;
97
type function_decl2 = {
99
f2_flags : func2_flags list;
100
f2_args : (int * string) list;
101
mutable f2_nregs : int;
102
mutable f2_codelen : action_count;
107
| TryVariable of string
110
tr_style : try_style;
111
mutable tr_trylen : action_count;
112
mutable tr_catchlen : action_count option;
113
mutable tr_finallylen : action_count option
238
| AGetURL of string * string
240
| AStringPool of string list
241
| AWaitForFrame of int * int
242
| ASetTarget of string
243
| AGotoLabel of string
244
| AWaitForFrame2 of int
245
| AFunction2 of function_decl2
248
| APush of push_item list
249
| AJump of action_count
251
| AFunction of function_decl
252
| ACondJump of action_count
253
| ACallFrame (* no data *)
254
| AGotoFrame2 of bool * int option
256
| AUnknown of int * unknown
258
type actions = action DynArray.t
261
mutable h_version : int;
262
mutable h_size : rect;
263
mutable h_fps : float16;
264
mutable h_frame_count : int;
265
mutable h_compressed : bool;
269
mutable exp_id : int;
273
type do_init_action = {
274
mutable dia_id : int;
275
dia_actions : actions;
286
mutable sts_id : int;
293
mutable sfb_cid : int;
297
type shape_fill_style =
300
| SFSLinearGradient of matrix * gradient
301
| SFSRadialGradient of matrix * gradient * int option
302
| SFSBitmap of sfs_bitmap
304
type shape_line_style = {
307
sls_unk : int option;
310
type shape_new_styles = {
311
sns_fill_styles : shape_fill_style list;
312
sns_line_styles : shape_line_style list;
317
type shape_change_style_record = {
318
scsr_move : (int * int * int) option;
319
scsr_fs0 : int option;
320
scsr_fs1 : int option;
321
scsr_ls : int option;
322
scsr_new_styles : shape_new_styles option;
325
type shape_curved_edge_record = {
333
type shape_straight_edge_record = {
335
sser_line : int option * int option;
339
| SRStyleChange of shape_change_style_record
340
| SRCurvedEdge of shape_curved_edge_record
341
| SRStraightEdge of shape_straight_edge_record
343
type shape_records = {
346
srs_records : shape_record list;
349
type shape_with_style = {
350
sws_fill_styles : shape_fill_style list;
351
sws_line_styles : shape_line_style list;
352
sws_records : shape_records;
358
sh_bounds2 : (rect * int) option;
359
sh_style : shape_with_style;
362
type filter_gradient = {
363
fgr_colors : (rgba * int) list;
368
| FDropShadow of unknown
372
| FGradientGlow of filter_gradient
373
| FAdjustColor of unknown
374
| FGradientBevel of filter_gradient
377
mutable jpg_id : int;
382
mutable jp2_id : int;
388
mutable jp3_id : int;
391
jp3_alpha_data : string;
394
type bitmap_lossless = {
395
mutable bll_id : int;
403
mutable msh_id : int;
404
msh_start_bounds : rect;
405
msh_end_bounds : rect;
410
mutable ft2_id : int;
415
mutable ft3_id : int;
420
mutable fgl_id : int;
430
mutable txr_font : (int * int) option;
431
txr_color : color option;
434
txr_glyphs : text_glyph list;
438
mutable txt_id : int;
439
txt_bounds : big_rect;
443
txt_records : text_record list;
446
type button_record = {
448
mutable btr_cid : int;
451
btr_color : color_transform_alpha option;
454
type button_action = {
456
bta_actions : actions;
460
mutable bt2_id : int;
461
bt2_track_as_menu : bool;
462
bt2_records : button_record list;
463
bt2_actions : button_action list;
466
type remove_object = {
467
mutable rmo_id : int;
471
type edit_text_layout = {
473
edtl_left_margin : int;
474
edtl_right_margin : int;
480
mutable edt_id : int;
482
mutable edt_font : (int * int) option;
483
edt_color : rgba option;
484
edt_maxlen : int option;
485
edt_layout : edit_text_layout option;
486
edt_variable : string;
487
edt_text : string option;
489
edt_multiline : bool;
503
| TRemoveObject of remove_object
504
| TBitsJPEG of bitmap_jpg
505
| TJPEGTables of string
508
| TDoAction of actions
510
| TStartSound of start_sound
511
| TBitsLossless of bitmap_lossless
512
| TBitsJPEG2 of bitmap_jpg2
515
| TPlaceObject2 of place_object
516
| TRemoveObject2 of int
519
| TButton2 of button2
520
| TBitsJPEG3 of bitmap_jpg3
521
| TBitsLossless2 of bitmap_lossless
522
| TEditText of edit_text
524
| TFrameLabel of string * char option
525
| TSoundStreamHead2 of unknown
526
| TMorphShape of morph_shape
528
| TExport of export list
529
| TDoInitAction of do_init_action
530
| TVideoStream of unknown
531
| TVideoFrame of unknown
533
| TPlaceObject3 of place_object
534
| TFontGlyphs of font_glyphs
535
| TTextInfo of unknown
538
| TShape5 of int * string
539
| TUnknown of int * unknown
543
mutable textended : bool;
544
mutable tdata : tag_data;
549
cle_key : char option;
550
cle_actions : actions;
556
mutable po_cid : int option;
557
po_matrix : matrix option;
558
po_color : color_transform_alpha option;
559
po_ratio : float16 option;
560
po_inst_name : string option;
561
po_clip_depth : int option;
562
po_events : clip_event list option;
563
po_filters : filter list option;
564
po_blend : int option;
565
po_bcache : int option;
574
type swf = header * tag list
576
let __deflate = ref (fun (_:unit IO.output) -> assert false)
577
let __inflate = ref (fun _ -> assert false)
578
let __parser = ref (fun _ -> assert false)
579
let __printer = ref (fun (_:unit IO.output) _ -> ())
581
exception Error of string
583
let error msg = raise (Error msg)
585
let warnings = ref true
588
let sign , f = (if f < 0. then true , 0. -. f else false , f) in
589
let high = int_of_float f in
590
let low = int_of_float ((f -. (float high)) *. 256.) in
591
if high > 127 then failwith "to_float16";
592
(high lsl 8) lor (if sign then low lor (1 lsl 15) else low)
594
let parse (ch : IO.input) =
597
let write (ch : 'a IO.output) (data : swf) =
598
!__printer (Obj.magic ch) data
600
let deflate (ch : 'a IO.output) =
601
(Obj.magic (!__deflate (Obj.magic ch) : unit IO.output) : 'a IO.output)
603
let inflate (ch : IO.input) =
604
(!__inflate ch : IO.input)