swfexpdc.h

Go to the documentation of this file.
00001 // $Id: swfexpdc.h 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 #ifndef INC_FLASH_EXPORT_DC
00099 #define INC_FLASH_EXPORT_DC
00100 
00101 #include "kerneldc.h"
00102 //#include "fillattr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00103 
00104 #include "swfshape.h"
00105 #include "swfbitmp.h"
00106 #include "swffont.h"
00107 #include "swftext.h"
00108 #include "swfbuttn.h"
00109 #include "swfsprit.h"
00110 #include "swfplace.h"
00111 
00112 // Constants for Flash export.
00113 #define FLASH_VERSION           4
00114 #define FLASH_FRAME_RATE        0x0c00  // 12.0 frames per second.
00115 #define FLASH_FRAMES            0x0001  // Only one frame.
00116 
00117 #define FLASH_MAX_SHORT         63      // Max length of a short tag header.
00118 #define FLASH_SCALE             50      // Scale to convert millipoints to twips.
00119 
00120 #define FLASH_RAMP_WIDTH        32768   // Width of the colour ramp for gradient fills.
00121 #define FLASH_FIXED_ONE         65536   // 1 in the 16.16 fixed point scheme used by Flash.
00122 
00123 #define FLASH_NO_FILL           0xff    // Tag for no fills being used. (Not part of SWF.)
00124 #define FLASH_FLAT_FILL         0x00    // Tag for a flat fill being used.
00125 #define FLASH_LINEAR_FILL       0x10    // Tag for linear fills.
00126 #define FLASH_RADIAL_FILL       0x12    // Tag for radial fills.
00127 #define FLASH_TILED_BITMAP      0x40    // Tiled bitmap fill.
00128 #define FLASH_CLIPPED_BITMAP    0x41    // Clipped bitmap fill.
00129 
00130 #define FLASH_BACKGROUND_TAG    9       // Background colour Tag.
00131 #define FLASH_SHAPE_TAG         2       // DefineShape Tag.
00132 #define FLASH_SHAPE3_TAG        32      // DefineShape3 Tag.
00133 #define FLASH_BITS_TAG          20      // DefineBitsLossless Tag.
00134 #define FLASH_BITS2_TAG         36      // DefineBitsLossless2 Tag.
00135 #define FLASH_END_FILE_TAG      0       // End of file tag.
00136 #define FLASH_SHOW_FRAME_TAG    1       // Show the frame.
00137 #define FLASH_PLACE_OBJECT_TAG  26      // Place an object. (Using PlaceObject2)
00138 #define FLASH_TEXT_TAG          33      // DefineText2 Tag.
00139 #define FLASH_FONT_TAG          10      // DefineFont Tag.
00140 #define FLASH_FONT_INFO_TAG     13      // DefineFontInfo Tag.
00141 #define FLASH_BUTTON_TAG        7       // DefineButton Tag.
00142 #define FLASH_SPRITE_TAG        39      // DefineSprite tag.
00143 
00144 #define FLASH_BUTTON_HIT        8       // Hit test this button.
00145 #define FLASH_BUTTON_DOWN       4       // State when it's down.
00146 #define FLASH_BUTTON_OVER       2       // State when cursor is over.
00147 #define FLASH_BUTTON_UP         1       // State when button is released up.
00148 
00149 #define FLASH_GET_URL           0x83    // Action tag for the "Get URL" script.
00150 
00151 #define FLASH_FONT_SIZE         51200   // Default font size for exporting text shapes.
00152 
00153 /********************************************************************************************
00154 
00155 >   class FlashExportDC : public ExportDC
00156 
00157     Author:     Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
00158     Created:    20/8/99
00159     Purpose:    Outline for a Flash export DC.
00160     SeeAlso:    -
00161 
00162 ********************************************************************************************/
00163 
00164 class FlashExportDC : public ExportDC
00165 {
00166 public:
00167     FlashExportDC ( void );
00168     FlashExportDC ( Filter *Parent );                   // Constructor.
00169     virtual ~FlashExportDC ( void );                    // Destructor.
00170     BOOL Init ( CCLexFile *pFile );                     // Use base class init() function.
00171 
00172     BOOL CreateHeader ( DocColour Background,
00173                         DocRect ImageBounds );
00174 
00175     BOOL EndFile ( void );
00176 
00177     BOOL WritePath ( FlashShapeRecord *pPath );         // Write a path to the file.
00178 
00179     BOOL WriteMoveTo ( DocCoord Position,               // Write a move to.
00180                        UINT32 ChangeLine,
00181                        UINT32 ChangeFill0,
00182                        UINT32 ChangeFill1);
00183 
00184     BOOL WriteEdgeRecord ( DocCoord *Coords,
00185                            DocCoord *MoveTo,
00186                            PathVerb *Verb,
00187                            INT32 NumCoords,
00188                            UINT32 LineStyle,
00189                            UINT32 Fill0,
00190                            UINT32 Fill1,
00191                            double Tolerance = 100.0f,
00192                            BOOL IsCircular = FALSE );
00193 
00194     UINT32 CountBits ( INT32 Value,                     // Count the number of set bits.
00195                      BOOL IsSigned = TRUE );
00196 
00197     BOOL WriteBoundingBox ( DocRect Bounds );
00198     BOOL WriteBits ( INT32 Value,                       // Write Bits bits to an output file.
00199                      UINT32 Bits );
00200     BOOL WriteBackgroundColour ( DocColour Background );// Write background colour tag.
00201     BOOL WriteColour ( DocColour Col );                 // Write RGB Colour value to disk.
00202     BOOL WriteColour ( FlashColour Col );               // Write RGB Colour value to disk.
00203     BOOL WriteHeader ( UINT8 sTag,                      // Write a header tag to the file.
00204                        UINT32 lSize );
00205     FilePos WriteHeader ( UINT8 sTag,                   // Write a header tag.
00206                           UINT32 lSize,
00207                           WORD ID );
00208     BOOL ByteAlign ( void );                            // Align data in output file.
00209     BOOL Write ( const void *Value,                     // Wrapper for the write function.
00210                  UINT32 Size );
00211 
00212     inline BOOL WriteByte ( BYTE Value );               // Write a BYTE value.
00213     inline BOOL WriteWord ( WORD Value );               // Write a WORD value.
00214     inline BOOL WriteLong ( INT32 Value );              // Write a INT32 value.
00215 
00216     BOOL WritePlaceObject ( FlashPlaceObject *pPlace ); // Write a place object tag.
00217 
00218     BOOL WritePlaceObject ( FlashPlaceObject *pPlace,   // Write a place object tag.
00219                             WORD Depth );
00220 
00221     BOOL WriteLineTo ( DocCoord Start,                  // Write a line to.
00222                        DocCoord End );
00223 
00224 
00225     BOOL WriteCurveTo ( DocCoord Start,                 // Write a curve section.
00226                         DocCoord Control,
00227                         DocCoord End );
00228 
00229     BOOL ExportCurve ( DocCoord &Start,                 // Prepares a curveto for export.
00230                        DocCoord &Control1,
00231                        DocCoord &Control2,
00232                        DocCoord &End,
00233                        double Tolerance );
00234 
00235     BOOL CalculateIntersection ( DocCoord &Start1,      // Calculates an intersection.
00236                                  DocCoord &End1,
00237                                  DocCoord &Start2,
00238                                  DocCoord &End2,
00239                                  DocCoord &Intersection );
00240 
00241     static DocCoord CalculateMidpoint ( DocCoord Point1,
00242                                         DocCoord Point2 );
00243 
00244     BOOL WriteText ( FlashTextRecord *pText );
00245 
00246     BOOL WriteDefineFont ( FlashFontRecord *pRecord );
00247 
00248     BOOL WriteDefineFontInfo ( FlashFontRecord *pRecord );
00249 
00250     BOOL WritePNG ( OILBitmap   *pBitmap,               // Writes a DefineBitsLossless tag.
00251                     WORD        BitmapID,
00252                     UINT32      Alpha,
00253                     BOOL        IsContoned );
00254 
00255     BOOL WriteTransparentBitmap ( OILBitmap *pBitmap,   // Writes a bitmap fill.
00256                                   WORD      BitmapID,
00257                                   DocColour Colour );
00258 
00259     BOOL WriteShadowBitmap ( OILBitmap  *pBitmap,       // Writes a shadow bitmap.
00260                              WORD       BitmapID,
00261                              DocColour  Colour,
00262                              UINT32     Darkness );
00263 
00264     BOOL WriteURLScript ( FlashButtonRecord *pButton ); // Creates a button record.
00265 
00266     BOOL ProcessSprite ( FlashSprite *pSprite,          // Processes a sprite record before
00267                          FlashButtonRecord *pButton );  // writing it out.
00268 
00269     BOOL WriteSprite ( FlashSprite *pSprite );          // Creates a sprite record.
00270 
00271     // Static member functions.
00272     static double CalculateLength ( DocCoord Delta );       // Calculates the length of a line.
00273     static INT32 CalculateLongLength ( DocCoord Delta );        // Calculates the length of a line.
00274 
00275 private:
00276 
00277     BOOL ProcessFill ( FlashShapeRecord *pShape,        // Set up the fill.
00278                        DocCoord *MoveTo );
00279 
00280     BOOL Write32BitBitmap ( OILBitmap   *pBitmap,       // Writes a true colour bitmap out.
00281                             WORD        BitmapID,
00282                             UINT32      Alpha );
00283 
00284     BOOL Write8BitBitmap ( OILBitmap    *pBitmap,       // Writes a 256 colour bitmap out.
00285                            WORD         BitmapID,
00286                            UINT32           Transparency,
00287                            BOOL         Alpha );
00288 
00289     FilePos Write8BitHeader ( OILBitmap *pBitmap,       // Writes the header for a bitmap.
00290                               WORD      BitmapID,
00291                               UINT32        NumColours,
00292                               BOOL      Transparent );
00293 
00294     BOOL Write8BitBody ( OILBitmap  *pBitmap,           // Writes out the bitmap's body.
00295                          FilePos    StartPos );
00296 
00297     BOOL WriteBitmapBits ( OILBitmap *pBitmap );
00298 
00299     void Transform ( DocCoord *Point,                   // Puts a point in Flash coordinates.
00300                      DocCoord *MoveTo = NULL );
00301 
00302     void Transform ( DocRect *Bounds );                 // Convert a BB into Flash coordinates.
00303 
00304     BOOL WriteMatrix ( DocCoord &Translate,             // Write a matrix to the file.
00305                        INT32 ScaleX = FLASH_FIXED_ONE,
00306                        INT32 ScaleY = FLASH_FIXED_ONE,
00307                        INT32 SkewX = 0,
00308                        INT32 SkewY = 0 );
00309 
00310     BOOL WriteRotationMatrix ( DocCoord &Translate,     // Write a rotation matrix.
00311                                INT32 ScaleX = FLASH_FIXED_ONE,
00312                                INT32 ScaleY = FLASH_FIXED_ONE,
00313                                double SinTheta = 0,
00314                                double CosTheta = 1.0f );
00315 
00316     void CalculateTrigValues ( DocCoord &StartPoint,    // Calculates the values for the matrix.
00317                                DocCoord &EndPoint,
00318                                INT32 &Length,
00319                                double &SinTheta,
00320                                double &CosTheta );
00321 
00322     BOOL WriteGradientFill ( FlashShapeRecord *pShape,
00323                              DocCoord *MoveTo );
00324 
00325     BOOL WriteBitmapFill ( FlashShapeRecord *pShape,
00326                            DocCoord *MoveTo );
00327 
00328     BOOL WriteTextMatrix ( INT32 ScaleX,
00329                            INT32 ScaleY,
00330                            INT32 SkewX,
00331                            INT32 SkewY,
00332                            const FIXED16 &Aspect );
00333 
00334     BOOL WriteTextRecord ( FlashTextRecord *pText );
00335 
00336     FilePos WriteChangeText ( const FlashColour &TextColour,
00337                               WORD Size,
00338                               WORD Style,
00339                               INT8 YOffset,
00340                               UINT32 HasColour,
00341                               UINT32 HasFont,
00342                               UINT32 HasYOffset );
00343 
00344     BOOL WriteGlyphHeader ( FilePos Start,
00345                             BYTE GlyphCount );
00346 
00347     BOOL WriteTagSize ( FilePos StartPos );
00348 
00349     void BuildComplexRotation ( DocCoord &Position,     // Creates a rotation matrix.
00350                                 INT32 &ScaleX,
00351                                 INT32 &ScaleY,
00352                                 INT32 &SkewX,
00353                                 INT32 &SkewY,
00354                                 const DocCoord &Centre,
00355                                 INT32 SinTheta,
00356                                 INT32 CosTheta );
00357 
00358     BOOL WriteComplexRotation ( DocCoord Position,      // Writes a rotation matrix.
00359                                 INT32 ScaleX,
00360                                 INT32 ScaleY,
00361                                 INT32 SkewX,
00362                                 INT32 SkewY,
00363                                 const DocCoord &Centre,
00364                                 INT32 SinTheta,
00365                                 INT32 CosTheta );
00366 
00367     BOOL WriteButtonRecord ( WORD ObjectID,             // Writes a button record.
00368                              BYTE State,
00369                              DocCoord Position,
00370                              BOOL DoTransform );
00371 
00372     BOOL WriteGetURL ( FlashButtonRecord *pButton );    // Writes a get URL Flash script.
00373 
00374     // Member variables.
00375     BYTE        m_bOutput;                              // Bitwise data to be outputted.
00376     INT32           m_bCurrentBit;                          // Next bit to be written to.
00377     WORD        mDepth;                                 // Depth of current shape.
00378     INT32       mTranslateX;                            // Used by Translate ().
00379     INT32       mTranslateY;                            // Used by Translate ().
00380     DocCoord    mLowCorner;                             // The low corner of the image.
00381     Filter      *pFilter;                               // Pointer to parent.
00382 };
00383 
00384 #endif

Generated on Sat Nov 10 03:47:06 2007 for Camelot by  doxygen 1.4.4