-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_test4.c
151 lines (111 loc) · 3.95 KB
/
gen_test4.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
* Copyright (C) 2002 Ben Evans <[email protected]>
* 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.
*
*/
/* Test the background colour test flag */
#include "swf_types.h"
#include "swf_parse.h"
#include "swf_movie.h"
#include "swf_serialise.h"
#include "swf_destroy.h"
#include <stdio.h>
#define NUMFRAMES 60
#define FRAMERATE 15
void usage (char * name);
void
usage (char * name)
{
fprintf (stderr, "Usage: %s <filename> <object number>\n", name);
}
SWF_U16 swf_get_object_id(swf_tagrecord * mytag, int * error);
SWF_U16
swf_get_object_id(swf_tagrecord * mytag, int * error)
{
return (((SWF_U16) mytag->buffer->raw[1]) << 8) | (SWF_U16) mytag->buffer->raw[0];
}
int main (int argc, char *argv[]) {
swf_movie * movie;
int error = SWF_ENoError;
swf_parser * parser;
swf_header * hdr;
swf_tagrecord * temp;
swf_matrix * m3;
if ((m3 = (swf_matrix *) calloc (1, sizeof (swf_matrix))) == NULL) {
error = SWF_EMallocFailure;
return 1;
}
/* First, get a parser up */
parser = swf_parse_create("swfs/ibm.swf", &error);
if (parser == NULL) {
fprintf (stderr, "Failed to create SWF context\n");
return -1;
}
printf ("Name of file is '%s'\n", parser->name);
printf("----- Reading the file input header -----\n");
hdr = swf_parse_header(parser, &error);
if (hdr == NULL) {
fprintf (stderr, "Failed to parse headers\n");
exit(1);
}
printf("FWS\n");
printf("File version \t%"pSWF_U32"\n", hdr->version);
printf("File size \t%"pSWF_U32"\n", hdr->size);
printf("Movie width \t%lu\n", (hdr->bounds->xmax - hdr->bounds->xmin) / 20);
printf("Movie height \t%lu\n", (hdr->bounds->ymax - hdr->bounds->ymin) / 20);
printf("Xmin: \t%lu\n", (hdr->bounds->xmin / 20));
printf("Xmax: \t%lu\n", (hdr->bounds->xmax / 20));
printf("Ymin: \t%lu\n", (hdr->bounds->ymin / 20));
printf("Ymax: \t%lu\n", (hdr->bounds->ymax / 20));
printf("Frame rate \t%"pSWF_U32"\n", hdr->rate);
printf("Frame count \t%"pSWF_U32"\n", hdr->count);
printf("\n----- Reading movie details -----\n");
/* Now generate the output movie */
if ((movie = swf_make_movie(&error)) == NULL) {
fprintf (stderr, "Fail\n");
return 1;
}
/* Right, now we need a tagrecord.. */
temp = swf_make_triangle(movie, &error);
/* Need to calloc a (raw) buffer for temp... */
if ((temp->buffer->raw = (SWF_U8 *) calloc (10240, sizeof (SWF_U8))) == NULL) {
fprintf (stderr, "Calloc Fail\n");
return 1;
}
swf_serialise_defineshape(temp->buffer, &error, (swf_defineshape *) temp->tag);
temp->serialised = 1;
/* Ensure we import a good header... */
movie->header = hdr;
movie->name = (char *) "ben4.swf";
movie->header->rate = FRAMERATE * 256;
/* Do the frames */
swf_add_setbackgroundcolour(movie, &error, 0, 255, 0, 255);
swf_dump_tag(movie, &error, temp);
m3->a = m3->d = 1 * 256 * 256;
m3->b = m3->c = 0;
m3->tx = 0 * 20;
m3->ty = 0 * 20;
swf_add_placeobject(movie, &error, m3, 1, 2);
swf_add_showframe(movie, &error);
swf_add_end(movie, &error);
swf_make_finalise(movie, &error);
printf("foo 3\n");
swf_destroy_movie(movie);
printf("foo 4\n");
swf_destroy_parser(parser);
swf_free(m3);
fprintf (stderr, "OK\n");
return 0;
}