1 /* 2 Ming, an SWF output library 3 Copyright (C) 2002 Opaque Industries - http://www.opaque.net/ 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library 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 GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 19 20 /* $Id$ */ 21 22 #include "ming.h" 23 #include "libming.h" 24 #include "blocks/character.h" 25 #include "font_util.h" 26 #include "shape_cubic.h" 27 #include "blocks/error.h" 28 #include "ming_config.h" 29 30 31 int SWF_versionNum = 5; 32 int SWF_compression = -1; 33 34 float Ming_scale = 20.0; 35 int Ming_cubicThreshold = 10000; 36 37 38 /* 39 * module-wide initialization. 40 * returns non-zero if error. 41 */ 42 Ming_init()43int Ming_init() 44 { 45 SWF_gNumCharacters = 0; 46 SWF_versionNum = 5; 47 48 Ming_cubicThreshold = 10000; 49 Ming_scale = 20.0; 50 51 return 0; 52 } 53 54 55 void Ming_cleanup()56Ming_cleanup() 57 { 58 Ming_cleanupFonts(); 59 } 60 61 /* 62 * Set output compression level. 63 * This function sets the value of the compression level to be used when 64 * generating output. The level should be a value between 1 and 9 inclusive 65 * and corresponds to compression levels used by libz. 66 * Returns previous value. 67 */ 68 int Ming_setSWFCompression(int level)69Ming_setSWFCompression(int level /* new compression level */) 70 { 71 int oldlevel = SWF_compression; 72 SWF_compression = level; 73 return oldlevel; 74 } 75 76 /* 77 * Set the global scaling factor 78 */ Ming_setScale(float scale)79void Ming_setScale(float scale /* New scaling factor */) 80 { 81 Ming_scale = scale; 82 } 83 84 /* 85 * Get the global scaling factor 86 * returns the current global scaling factor 87 */ Ming_getScale()88float Ming_getScale() 89 { 90 return Ming_scale; 91 } 92 93 /* 94 * Set the threshold used when approximating cubic quadratic shapes. 95 */ Ming_setCubicThreshold(int num)96void Ming_setCubicThreshold(int num /* New threshold value */) 97 { 98 Ming_cubicThreshold = num; 99 } 100 101 /* 102 * Set the function that gets called when a warning occurs within the library 103 * This function sets function to be called when a warning occurs within the 104 * library. The default function prints the warning message to stdout. 105 * Returns the previously-set warning function. 106 */ Ming_setWarnFunction(SWFMsgFunc warn)107SWFMsgFunc Ming_setWarnFunction(SWFMsgFunc warn) 108 { 109 return setSWFWarnFunction(warn); 110 } 111 112 /* 113 * Set the function that gets called when an error occurs within the library 114 * This function sets function to be called when an error occurs within the 115 * library. The default function prints the error mesage to stdout and exits. 116 * Returns the previously-set error function. 117 */ Ming_setErrorFunction(SWFMsgFunc error)118SWFMsgFunc Ming_setErrorFunction(SWFMsgFunc error) 119 { 120 return setSWFErrorFunction(error); 121 } 122 123 /* 124 * set the version of SWF to produce on output 125 * This function set the version of SWF to be produced by the library. Only 126 * versions 4 through 8 inclusive are supported at this time. 127 */ Ming_useSWFVersion(int version)128void Ming_useSWFVersion(int version /* Flash version */) 129 { 130 static int called=0; 131 132 if(version < 4 || version > 9) 133 SWF_error("Only SWF versions 4 to 9 are currently supported!\n"); 134 135 if ( called && version != SWF_versionNum ) 136 { 137 SWF_warn("WARNING: changing SWF target version during a run\n" 138 " might result in malformed SWF output.\n" 139 " You don't have to worry if you're careful about\n" 140 " not mixing different version blocks in a movie.\n"); 141 } 142 143 called=1; 144 145 SWF_versionNum = version; 146 147 } 148 149 150 /* 151 * Local variables: 152 * tab-width: 2 153 * c-basic-offset: 2 154 * End: 155 */ 156