big merge from master, fix rpm creation, drop fetching swfdec
[gnash.git] / testsuite / misc-ming.all / BitmapSmoothingTest.c
blob09888e294ea69e137091ad7c00ce0f8fd44c78b9
1 /***********************************************************************
3 * Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
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 3 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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 ***********************************************************************
23 * Test case for the Bitmap smoothing
24 * Requires: MING-0.4.3 (00040300)
26 ***********************************************************************/
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <ming.h>
32 #include "ming_utils.h"
34 int
35 main(int argc, char **argv)
37 SWFMovie mo;
38 SWFInput in;
39 SWFBitmap bitmap;
40 SWFShape shpSmt;
41 SWFShape shpHrd;
42 SWFMovieClip mc;
43 SWFDisplayItem it;
44 int swfversion;
45 SWFFont font;
46 SWFMovieClip dejagnuclip;
47 char outputFilename[256];
48 FILE* imgfile;
50 if ( argc < 2 ) {
51 fprintf(stderr, "Usage: %s <swf_version>\n", argv[0]);
52 exit(EXIT_FAILURE);
55 swfversion = atoi(argv[1]);
56 sprintf(outputFilename, "BitmapSmoothingTest-v%d.swf", swfversion);
58 /*********************************************
60 * Initialization
62 *********************************************/
65 puts("Setting things up");
67 Ming_init();
68 Ming_useSWFVersion (swfversion);
70 mo = newSWFMovieWithVersion(swfversion);
72 /****************************************************
73 * Create filled shapes mc
74 ****************************************************/
75 imgfile = fopen(MEDIADIR"/vstroke.png", "rb");
76 if (!imgfile) {
77 fprintf(stderr, "Failed to open bitmap file");
78 return EXIT_FAILURE;
81 // Note that recent ming version have the more convenient
82 // newSWFInput_filename() function, but we want to support
83 // older versions.
84 in = newSWFInput_file(imgfile);
85 bitmap = newSWFBitmap_fromInput(in);
86 if (!bitmap) {
87 return EXIT_FAILURE;
90 shpSmt = newSWFShapeFromBitmap(bitmap,
91 SWFFILL_CLIPPED_BITMAP);
93 shpHrd = newSWFShapeFromBitmap(bitmap,
94 SWFFILL_NONSMOOTHED_CLIPPED_BITMAP);
96 mc = newSWFMovieClip();
97 SWFMovieClip_add(mc, (SWFBlock)shpSmt);
98 it = SWFMovieClip_add(mc, (SWFBlock)shpHrd);
99 SWFDisplayItem_moveTo(it, 0, 5);
100 SWFMovieClip_nextFrame(mc);
102 /****************************************************
103 * Create filled shapes mc, and scale it
104 ****************************************************/
106 it = SWFMovie_add(mo, (SWFBlock)mc);
107 SWFDisplayItem_scaleTo(it, 30, 10);
109 SWFMovie_setDimension(mo, SWFBitmap_getWidth(bitmap)*30, 500);
111 /****************************************************
112 * Add dejagnu clip
113 ****************************************************/
115 font = get_default_font(MEDIADIR);
116 dejagnuclip = get_dejagnu_clip((SWFBlock)font, 10, 0, 0, 200, 200);
117 it = SWFMovie_add(mo, (SWFBlock)dejagnuclip);
118 SWFDisplayItem_setDepth(it, 200);
119 SWFDisplayItem_move(it, 0, 100);
121 /****************************************************
122 * TODO: Add actions
123 ****************************************************/
126 /****************************************************
127 * Save things up
128 ****************************************************/
130 printf("Saving %s\n", outputFilename);
132 SWFMovie_nextFrame(mo); /* showFrame */
134 SWFMovie_save(mo, outputFilename);
136 fclose(imgfile);
138 return EXIT_SUCCESS;