00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 #ifndef INC_FLASH_EXPORT_DC
00099 #define INC_FLASH_EXPORT_DC
00100
00101 #include "kerneldc.h"
00102
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
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
00156
00157
00158
00159
00160
00161
00162
00163
00164 class FlashExportDC : public ExportDC
00165 {
00166 public:
00167 FlashExportDC ( void );
00168 FlashExportDC ( Filter *Parent );
00169 virtual ~FlashExportDC ( void );
00170 BOOL Init ( CCLexFile *pFile );
00171
00172 BOOL CreateHeader ( DocColour Background,
00173 DocRect ImageBounds );
00174
00175 BOOL EndFile ( void );
00176
00177 BOOL WritePath ( FlashShapeRecord *pPath );
00178
00179 BOOL WriteMoveTo ( DocCoord Position,
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,
00195 BOOL IsSigned = TRUE );
00196
00197 BOOL WriteBoundingBox ( DocRect Bounds );
00198 BOOL WriteBits ( INT32 Value,
00199 UINT32 Bits );
00200 BOOL WriteBackgroundColour ( DocColour Background );
00201 BOOL WriteColour ( DocColour Col );
00202 BOOL WriteColour ( FlashColour Col );
00203 BOOL WriteHeader ( UINT8 sTag,
00204 UINT32 lSize );
00205 FilePos WriteHeader ( UINT8 sTag,
00206 UINT32 lSize,
00207 WORD ID );
00208 BOOL ByteAlign ( void );
00209 BOOL Write ( const void *Value,
00210 UINT32 Size );
00211
00212 inline BOOL WriteByte ( BYTE Value );
00213 inline BOOL WriteWord ( WORD Value );
00214 inline BOOL WriteLong ( INT32 Value );
00215
00216 BOOL WritePlaceObject ( FlashPlaceObject *pPlace );
00217
00218 BOOL WritePlaceObject ( FlashPlaceObject *pPlace,
00219 WORD Depth );
00220
00221 BOOL WriteLineTo ( DocCoord Start,
00222 DocCoord End );
00223
00224
00225 BOOL WriteCurveTo ( DocCoord Start,
00226 DocCoord Control,
00227 DocCoord End );
00228
00229 BOOL ExportCurve ( DocCoord &Start,
00230 DocCoord &Control1,
00231 DocCoord &Control2,
00232 DocCoord &End,
00233 double Tolerance );
00234
00235 BOOL CalculateIntersection ( DocCoord &Start1,
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,
00251 WORD BitmapID,
00252 UINT32 Alpha,
00253 BOOL IsContoned );
00254
00255 BOOL WriteTransparentBitmap ( OILBitmap *pBitmap,
00256 WORD BitmapID,
00257 DocColour Colour );
00258
00259 BOOL WriteShadowBitmap ( OILBitmap *pBitmap,
00260 WORD BitmapID,
00261 DocColour Colour,
00262 UINT32 Darkness );
00263
00264 BOOL WriteURLScript ( FlashButtonRecord *pButton );
00265
00266 BOOL ProcessSprite ( FlashSprite *pSprite,
00267 FlashButtonRecord *pButton );
00268
00269 BOOL WriteSprite ( FlashSprite *pSprite );
00270
00271
00272 static double CalculateLength ( DocCoord Delta );
00273 static INT32 CalculateLongLength ( DocCoord Delta );
00274
00275 private:
00276
00277 BOOL ProcessFill ( FlashShapeRecord *pShape,
00278 DocCoord *MoveTo );
00279
00280 BOOL Write32BitBitmap ( OILBitmap *pBitmap,
00281 WORD BitmapID,
00282 UINT32 Alpha );
00283
00284 BOOL Write8BitBitmap ( OILBitmap *pBitmap,
00285 WORD BitmapID,
00286 UINT32 Transparency,
00287 BOOL Alpha );
00288
00289 FilePos Write8BitHeader ( OILBitmap *pBitmap,
00290 WORD BitmapID,
00291 UINT32 NumColours,
00292 BOOL Transparent );
00293
00294 BOOL Write8BitBody ( OILBitmap *pBitmap,
00295 FilePos StartPos );
00296
00297 BOOL WriteBitmapBits ( OILBitmap *pBitmap );
00298
00299 void Transform ( DocCoord *Point,
00300 DocCoord *MoveTo = NULL );
00301
00302 void Transform ( DocRect *Bounds );
00303
00304 BOOL WriteMatrix ( DocCoord &Translate,
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,
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,
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,
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,
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,
00368 BYTE State,
00369 DocCoord Position,
00370 BOOL DoTransform );
00371
00372 BOOL WriteGetURL ( FlashButtonRecord *pButton );
00373
00374
00375 BYTE m_bOutput;
00376 INT32 m_bCurrentBit;
00377 WORD mDepth;
00378 INT32 mTranslateX;
00379 INT32 mTranslateY;
00380 DocCoord mLowCorner;
00381 Filter *pFilter;
00382 };
00383
00384 #endif