#include <swfexpdc.h>
Inheritance diagram for FlashExportDC:

Public Member Functions | |
| FlashExportDC (void) | |
| Default constructor: Creates a DC for exporting Flash files. | |
| FlashExportDC (Filter *Parent) | |
| Constructor: Creates a DC for exporting Flash files. | |
| virtual | ~FlashExportDC (void) |
| Destructor. I'm not sure if this is needed, since export files are cleaned up for me elsewhere. | |
| BOOL | Init (CCLexFile *pFile) |
| Calls ExportDC::Init (). | |
| BOOL | CreateHeader (DocColour Background, DocRect ImageBounds) |
| Creates a Flash file header. | |
| BOOL | EndFile (void) |
| Tidies up the file.. | |
| BOOL | WritePath (FlashShapeRecord *pPath) |
| Converts and writes a path to a Flash file. | |
| BOOL | WriteMoveTo (DocCoord Position, UINT32 ChangeLine, UINT32 ChangeFill0, UINT32 ChangeFill1) |
| Writes a Flash Move To edge record. | |
| BOOL | WriteEdgeRecord (DocCoord *Coords, DocCoord *MoveTo, PathVerb *Verb, INT32 NumCoords, UINT32 LineStyle, UINT32 Fill0, UINT32 Fill1, double Tolerance=100.0f, BOOL IsCircular=FALSE) |
| Writes out a Flash edge record. | |
| UINT32 | CountBits (INT32 Value, BOOL IsSigned=TRUE) |
| Counts the number of significant bits in a value. | |
| BOOL | WriteBoundingBox (DocRect Bounds) |
| Create a bounding box, and write it into a file. | |
| BOOL | WriteBits (INT32 Value, UINT32 Bits) |
| Writes individual bits to the output file. | |
| BOOL | WriteBackgroundColour (DocColour Background) |
| Writes the background colour to the file. | |
| BOOL | WriteColour (DocColour Col) |
| Writes a DocColour to the file in the flash format. | |
| BOOL | WriteColour (FlashColour Col) |
| Writes the colour to the file. | |
| BOOL | WriteHeader (UINT8 sTag, UINT32 lSize) |
| Writes a section header to the file. | |
| FilePos | WriteHeader (UINT8 sTag, UINT32 lSize, WORD ID) |
| Writes a section header to the file, along with the ID tag. | |
| BOOL | ByteAlign (void) |
| Aligns bitwise values to byte boundaries.. | |
| BOOL | Write (const void *Value, UINT32 Size) |
| Forms a wrapper around all disk writes, with a small degree of error checking. | |
| BOOL | WriteByte (BYTE Value) |
| Writes a BYTE value to the disk file. | |
| BOOL | WriteWord (WORD Value) |
| Writes a short value (16 bits) to the disk file. | |
| BOOL | WriteLong (INT32 Value) |
| Writes an INT32 value (32 bits) to the disk file. | |
| BOOL | WritePlaceObject (FlashPlaceObject *pPlace) |
| It's a wrapper around the other WritePlaceObject () function, using the member variable mDepth to determine the "depth" in the image that the shape is to be rendered. | |
| BOOL | WritePlaceObject (FlashPlaceObject *pPlace, WORD Depth) |
| Writes a place object tag using the data contained in pPlace, and with an image depth of Depth. | |
| BOOL | WriteLineTo (DocCoord Start, DocCoord End) |
| Writes a Flash Line To edge record. | |
| BOOL | WriteCurveTo (DocCoord Start, DocCoord Control, DocCoord End) |
| Writes a Flash Curve To edge record. | |
| BOOL | ExportCurve (DocCoord &Start, DocCoord &Control1, DocCoord &Control2, DocCoord &End, double Tolerance) |
| Prepares a Bezier for export to a Flash file by converting it into a quadratic, and splitting the curve where necessary. | |
| BOOL | CalculateIntersection (DocCoord &Start1, DocCoord &End1, DocCoord &Start2, DocCoord &End2, DocCoord &Intersection) |
| Calculates the point of intersection between two lines with defined by a pair of points lying on each one. | |
| BOOL | WriteText (FlashTextRecord *pText) |
| Writes the contents of the FlashTextRecord into a file in the correct format for a Flash file. | |
| BOOL | WriteDefineFont (FlashFontRecord *pRecord) |
| Writes out a string DefineFont records. | |
| BOOL | WriteDefineFontInfo (FlashFontRecord *pRecord) |
| Writes out a string DefineFontInfo records. | |
| BOOL | WritePNG (OILBitmap *pBitmap, WORD BitmapID, UINT32 Alpha, BOOL IsContoned) |
| Writes a DIB into a Flash file as a PNG. | |
| BOOL | WriteTransparentBitmap (OILBitmap *pBitmap, WORD BitmapID, DocColour Colour) |
| Writes out a Zlib compressed bitmap record to the Flash file. This contains a transparent Camelot fill. | |
| BOOL | WriteShadowBitmap (OILBitmap *pBitmap, WORD BitmapID, DocColour Colour, UINT32 Darkness) |
| Writes out a Zlib compressed bitmap record to the Flash file. This contains a transparent bitmap representing the shadow. | |
| BOOL | WriteURLScript (FlashButtonRecord *pButton) |
| Creates a Flash button from the details stored in the FlashButtonRecord. This allows the file to call other URLs by clicking on any shape designated as a button. | |
| BOOL | ProcessSprite (FlashSprite *pSprite, FlashButtonRecord *pButton) |
| Parses through the list of sprites, and replaces any records containing a single shape with a direct reference to the shape in the relevant button record. If the sprite record contains multiple shapes, then it is written out to disk directly. | |
| BOOL | WriteSprite (FlashSprite *pSprite) |
| Writes out a sprite record to the file, which allows several shapes to be combined into a single button. | |
Static Public Member Functions | |
| static DocCoord | CalculateMidpoint (DocCoord Point1, DocCoord Point2) |
| Calculates the point of intersection between two lines with defined by a pair of points lying on each one. | |
| static double | CalculateLength (DocCoord Delta) |
| Calculates the length of a line between two points. | |
| static INT32 | CalculateLongLength (DocCoord Delta) |
| Calculates the length of a line between two points. | |
Private Member Functions | |
| BOOL | ProcessFill (FlashShapeRecord *pShape, DocCoord *MoveTo) |
| Determines which kind of fill is being used, and takes appropriate action. | |
| BOOL | Write32BitBitmap (OILBitmap *pBitmap, WORD BitmapID, UINT32 Alpha) |
| Writes out a Zlib compressed bitmap record to the Flash file. | |
| BOOL | Write8BitBitmap (OILBitmap *pBitmap, WORD BitmapID, UINT32 Transparency, BOOL Alpha) |
| Writes out a Zlib compressed bitmap record to the Flash file. | |
| FilePos | Write8BitHeader (OILBitmap *pBitmap, WORD BitmapID, UINT32 NumColours, BOOL Transparent) |
| Writes out the header for a 256 colour bitmap. | |
| BOOL | Write8BitBody (OILBitmap *pBitmap, FilePos StartPos) |
| Writes out the header for a 256 colour bitmap. | |
| BOOL | WriteBitmapBits (OILBitmap *pBitmap) |
| void | Transform (DocCoord *Point, DocCoord *MoveTo=NULL) |
| Transforms the co-ordinates of Point from Camelot space into Flash space. It's really a hack to replace the transformation matrix, until I work out how to initialise that properly. | |
| void | Transform (DocRect *Bounds) |
| Transforms the co-ordinates of Bounds from Camelot space into Flash space. The rectangle is resized so that lo is (0,0). | |
| BOOL | WriteMatrix (DocCoord &Translate, INT32 ScaleX=65536, INT32 ScaleY=65536, INT32 SkewX=0, INT32 SkewY=0) |
| Writes a Flash format matrix to the output file. Flash takes these values, and uses them to compose a matrix with this format: | ScaleX SkewY Translate.x | | SkewX ScaleY Translate.y |. | |
| BOOL | WriteRotationMatrix (DocCoord &Translate, INT32 ScaleX=65536, INT32 ScaleY=65536, double SinTheta=0, double CosTheta=1.0f) |
| This is a wrapper around the WriteMatrix method (above), except that it takes a cosine and sine, and assembles the appropriate rotation matrix. | |
| void | CalculateTrigValues (DocCoord &StartPoint, DocCoord &EndPoint, INT32 &Length, double &SinTheta, double &CosTheta) |
| Takes two points, and calculates the length, and the sine and cosine values for the angle of rotation from the x-axis. | |
| BOOL | WriteGradientFill (FlashShapeRecord *pShape, DocCoord *MoveTo) |
| Writes out a gradient fill to disk. | |
| BOOL | WriteBitmapFill (FlashShapeRecord *pShape, DocCoord *MoveTo) |
| Writes out a bitmap fill to disk. | |
| BOOL | WriteTextMatrix (INT32 ScaleX, INT32 ScaleY, INT32 SkewX, INT32 SkewY, const FIXED16 &Aspect) |
| Creates and writes the correct matrix for the current text string to the file. | |
| BOOL | WriteTextRecord (FlashTextRecord *pText) |
| Writes the DefineText's text record into the file. | |
| FilePos | WriteChangeText (const FlashColour &TextColour, WORD Size, WORD Style, INT8 YOffset, UINT32 HasColour, UINT32 HasFont, UINT32 HasYOffset) |
| Writes a record to the file to change the font style being used. | |
| BOOL | WriteGlyphHeader (FilePos Start, BYTE GlyphCount) |
| Fills in the number of glyphs used. | |
| BOOL | WriteTagSize (FilePos StartPos) |
| Fills in the number of byte used by the tag. | |
| void | BuildComplexRotation (DocCoord &Position, INT32 &ScaleX, INT32 &ScaleY, INT32 &SkewX, INT32 &SkewY, const DocCoord &Centre, INT32 SinTheta, INT32 CosTheta) |
| Creates a matrix which combines the the transformation in the passed in matrix, with the rotation described by CosTheta and SinTheta around the point Center. The inputted values (ScaleX, ScaleY, SkewY, SkewX, Position) are then reassigned the new matrix values, and since they're passed in as references, they return these to the calling function. | |
| BOOL | WriteComplexRotation (DocCoord Position, INT32 ScaleX, INT32 ScaleY, INT32 SkewX, INT32 SkewY, const DocCoord &Centre, INT32 SinTheta, INT32 CosTheta) |
| Creates a matrix (using the BuildComplexRotation methord), and writes it out the the Flash file being created. | |
| BOOL | WriteButtonRecord (WORD ObjectID, BYTE State, DocCoord Position, BOOL DoTransform) |
| Links a Flash shape record with the button, and sets this to be one of the states in use. | |
| BOOL | WriteGetURL (FlashButtonRecord *pButton) |
| Creates an action script within the Flash file that fetches the URL (pointed to by pButton), and displays it in the browser window. | |
Private Attributes | |
| BYTE | m_bOutput |
| INT32 | m_bCurrentBit |
| WORD | mDepth |
| INT32 | mTranslateX |
| INT32 | mTranslateY |
| DocCoord | mLowCorner |
| Filter * | pFilter |
Definition at line 164 of file swfexpdc.h.
|
|
Default constructor: Creates a DC for exporting Flash files.
Definition at line 144 of file swfexpdc.cpp. 00144 : ExportDC ( NULL ) 00145 { 00146 // Set the output variables to their correct setting. 00147 m_bOutput = 0; 00148 m_bCurrentBit = 7; 00149 mDepth = 1; 00150 pFilter = NULL; 00151 00152 mLowCorner.x = mLowCorner.y = 0; 00153 }
|
|
|
Constructor: Creates a DC for exporting Flash files.
Definition at line 166 of file swfexpdc.cpp. 00166 : ExportDC ( Parent ) 00167 { 00168 // Set the output variables to their correct setting. 00169 m_bOutput = 0; 00170 m_bCurrentBit = 7; 00171 mDepth = 1; 00172 pFilter = Parent; 00173 00174 mLowCorner.x = mLowCorner.y = 0; 00175 }
|
|
|
Destructor. I'm not sure if this is needed, since export files are cleaned up for me elsewhere.
Definition at line 189 of file swfexpdc.cpp.
|
|
||||||||||||||||||||||||||||||||||||
|
Creates a matrix which combines the the transformation in the passed in matrix, with the rotation described by CosTheta and SinTheta around the point Center. The inputted values (ScaleX, ScaleY, SkewY, SkewX, Position) are then reassigned the new matrix values, and since they're passed in as references, they return these to the calling function.
Definition at line 2651 of file swfexpdc.cpp. 02659 { 02660 // Reassign the variables to a series of doubles (as usual for extra precision), 02661 // and multiply the two matrices together in the process. The composition of this 02662 // new matrix is: 02663 // 02664 // | dScaleX dSkewX dPositionX | 02665 // | dSkewY dScaleY dPositionY | 02666 // | 0 0 1 | 02667 // 02668 // dShiftX and dShiftY are the values from the rotation matrix. Basically, you 02669 // shift the image so that it's centred around (0, 0), rotate it, and put it 02670 // back where it was. Effectively this involves compositing three matrices, and 02671 // the net result is identical to the usual rotation matrix, with the exception 02672 // of the translation values. 02673 double dShiftX = ( ( ( ( double ) - CosTheta * ( double ) Centre.x ) + 02674 ( ( double ) SinTheta * ( double ) Centre.y ) ) / FLASH_FIXED_ONE ) 02675 + ( double ) Centre.x; 02676 02677 double dShiftY = ( ( ( ( double ) - SinTheta * ( double ) Centre.x ) - 02678 ( ( double ) CosTheta * ( double ) Centre.y ) ) / FLASH_FIXED_ONE ) 02679 + ( double ) Centre.y; 02680 02681 // Now calculate the body of the matrix. 02682 double dScaleX = ( ( ( double ) ScaleX * ( double ) CosTheta ) - 02683 ( ( double ) SkewY * ( double ) SinTheta ) ) / 02684 FLASH_FIXED_ONE; 02685 02686 double dScaleY = ( ( ( double ) SkewX * ( double ) SinTheta ) + 02687 ( ( double ) ScaleY * ( double ) CosTheta ) ) / 02688 FLASH_FIXED_ONE; 02689 02690 double dSkewX = ( ( ( double ) SkewX * ( double ) CosTheta ) - 02691 ( ( double ) ScaleY * ( double ) SinTheta ) ) / 02692 FLASH_FIXED_ONE; 02693 02694 double dSkewY = ( ( ( double ) ScaleX * ( double ) SinTheta ) + 02695 ( ( double ) SkewY * ( double ) CosTheta ) ) / 02696 FLASH_FIXED_ONE; 02697 02698 double dPositionX = ( ( ( ( double ) Position.x * ( double ) CosTheta ) - 02699 ( ( double ) Position.y * ( double ) SinTheta ) ) / FLASH_FIXED_ONE ) + 02700 dShiftX; 02701 02702 double dPositionY = ( ( ( ( double ) Position.x * ( double ) SinTheta ) + 02703 ( ( double ) Position.y * ( double ) CosTheta ) ) / FLASH_FIXED_ONE ) + 02704 dShiftY; 02705 02706 // Cast the values back into longs, and the function is complete. 02707 ScaleX = ( INT32 ) dScaleX; 02708 ScaleY = ( INT32 ) dScaleY; 02709 SkewX = ( INT32 ) dSkewX; 02710 SkewY = ( INT32 ) dSkewY; 02711 Position.x = ( INT32 ) dPositionX; 02712 Position.y = ( INT32 ) dPositionY; 02713 }
|
|
|
Aligns bitwise values to byte boundaries..
Definition at line 544 of file swfexpdc.cpp. 00545 { 00546 BOOL Result = TRUE; 00547 00548 if ( m_bCurrentBit != 7 ) 00549 Result = WriteBits ( 0, m_bCurrentBit + 1 ); 00550 00551 return Result; 00552 }
|
|
||||||||||||||||||||||||
|
Calculates the point of intersection between two lines with defined by a pair of points lying on each one.
Definition at line 1172 of file swfexpdc.cpp. 01177 { 01178 double p, q; // Unused values describing where the lines meet. 01179 BOOL Result; // Return value. 01180 01181 // Calculate the vectors describing the direction of the two lines. 01182 NormCoord Dir1 ( End1.x - Start1.x, End1.y - Start1.y ); 01183 NormCoord Dir2 ( End2.x - Start2.x, End2.y - Start2.y ); 01184 01185 // Now normalise them, so that they are unit vectors. 01186 Dir1.Normalise (); 01187 Dir2.Normalise (); 01188 01189 // Calculate the point of intersection between the lines created between each 01190 // anchor point, and its nearest control point. 01191 Result = CCreateBevelTrapezoids::CalculateIntersection ( &Start1, &Dir1, 01192 &Start2, &Dir2, 01193 &Intersection, 01194 &p, &q ); 01195 01196 return Result; 01197 }
|
|
|
Calculates the length of a line between two points.
Definition at line 1482 of file swfexpdc.cpp. 01483 { 01484 // Convert the co-ordinates from longs to doubles. This prevents the variables over 01485 // flowing. 01486 double xSquared = ( ( double ) Delta.x ) * ( ( double ) Delta.x ); 01487 double ySquared = ( ( double ) Delta.y ) * ( ( double ) Delta.y ); 01488 01489 // Calculate the distance. 01490 double Result = sqrt ( xSquared + ySquared ); 01491 01492 // And return it. 01493 return Result; 01494 }
|
|
|
Calculates the length of a line between two points.
Definition at line 1508 of file swfexpdc.cpp. 01509 { 01510 // Call the other CalculateLength function. 01511 return ( INT32 ) CalculateLength ( Delta ); 01512 }
|
|
||||||||||||
|
Calculates the point of intersection between two lines with defined by a pair of points lying on each one.
Definition at line 1213 of file swfexpdc.cpp. 01215 { 01216 DocCoord Midpoint; 01217 01218 Midpoint.x = Point1.x + ( ( Point2.x - Point1.x ) / 2 ); 01219 Midpoint.y = Point1.y + ( ( Point2.y - Point1.y ) / 2 ); 01220 01221 return Midpoint; 01222 }
|
|
||||||||||||||||||||||||
|
Takes two points, and calculates the length, and the sine and cosine values for the angle of rotation from the x-axis.
Definition at line 1531 of file swfexpdc.cpp. 01536 { 01537 DocCoord Delta = EndPoint - StartPoint; 01538 Length = CalculateLongLength ( Delta ); 01539 01540 // Check that the length of the vector isn't zero, and thus avoid any nasty divide by 01541 // zero errors. 01542 if ( Length == 0 ) 01543 { 01544 // Set the angle to be 0 radians, and load the variables with the appropriate 01545 // values. 01546 SinTheta = 0; 01547 CosTheta = 1; 01548 } 01549 else 01550 { 01551 // Calculate the trignometric functions using the lengths of the sides of a 01552 // triangle. 01553 SinTheta = ( double ) Delta.y / ( double )Length; 01554 CosTheta = ( double ) Delta.x / ( double )Length; 01555 } 01556 }
|
|
||||||||||||
|
Counts the number of significant bits in a value.
Definition at line 323 of file swfexpdc.cpp. 00325 { 00326 UINT32 BitCount = 0; 00327 00328 // Add an extra bit in for negative values. 00329 if ( IsSigned ) 00330 BitCount = 1; 00331 00332 while ( Value ) 00333 { 00334 Value >>= 1; 00335 BitCount ++; 00336 } 00337 00338 return BitCount; 00339 }
|
|
||||||||||||
|
Creates a Flash file header.
Definition at line 228 of file swfexpdc.cpp. 00230 { 00231 // Calculate the size of the image. To save complications, I've moved the image to 00232 // 0,0, rather than from whatever bounds Camelot uses. 00233 mLowCorner.x = ImageBounds.lo.x / FLASH_SCALE; 00234 mLowCorner.y = ImageBounds.hi.y / FLASH_SCALE; 00235 00236 Transform ( &ImageBounds ); 00237 00238 // Write the header for the Flash file. 00239 Write ( "FWS", 3 ); // File ID tag. 00240 WriteByte ( 4 ); // Version number. 00241 WriteLong ( 0 ); // Space for file size. 00242 WriteBoundingBox ( ImageBounds ); // Bounding rectangle for image. 00243 WriteByte ( 0 ); // Frames per second. (Decimal part.) 00244 WriteByte ( 12 ); // Frames per second. (Integer part.) 00245 WriteWord ( 1 ); // Number of frames. 00246 WriteBackgroundColour ( Background ); // Background colour. 00247 00248 return TRUE; 00249 }
|
|
|
Tidies up the file..
Definition at line 262 of file swfexpdc.cpp. 00263 { 00264 // Write show frame. 00265 WriteHeader ( FLASH_SHOW_FRAME_TAG, 0 ); 00266 00267 // Write end of file. 00268 WriteHeader ( FLASH_END_FILE_TAG, 0 ); 00269 00270 // Rewind, and add the file size. 00271 ExportFile->seekIn ( 4 ); 00272 WriteLong ( (INT32) ExportFile->Size() ); 00273 00274 return TRUE; 00275 }
|
|
||||||||||||||||||||||||
|
Prepares a Bezier for export to a Flash file by converting it into a quadratic, and splitting the curve where necessary.
Definition at line 1067 of file swfexpdc.cpp. 01072 { 01073 // Calculate the point of intersection between the lines created between each 01074 // anchor point, and its nearest control point. This then acts as the control point 01075 // for the quadratic form of the Bezier. 01076 INT32 Length = CalculateLongLength ( End - Start ); 01077 DocCoord Control; 01078 01079 // Write subpixel lines out as a line. 01080 if ( Length < 20 ) 01081 { 01082 return WriteLineTo ( Start, End ); 01083 } 01084 // Otherwise calculate the control point, and render as a quadratic curve. 01085 else if ( CalculateIntersection ( Start, Control1, End, Control2, Control ) ) 01086 { 01087 // Now compare the midpoints of the quadratic and cubic forms of the Beziers. 01088 // This algorithm is based on a divide and conquer method of curve rendering, 01089 // and can be found in Ken Joy's online computer graphics notes at: 01090 // http://graphics.cs.ucdavis.edu/GraphicsNotes/Graphics-Notes.html 01091 01092 // The technique is to first calculate the midpoints between the start and 01093 // control points of a quadratic bezier, and then the midpoint between the 01094 // midpoints. This point lies in the middle of the curve. 01095 01096 DocCoord MidStartControl = CalculateMidpoint ( Start, Control ); 01097 DocCoord MidControlEnd = CalculateMidpoint ( Control, End ); 01098 01099 DocCoord QuadMidpoint = CalculateMidpoint ( MidStartControl, MidControlEnd ); 01100 01101 // Then process the cubic bezer using the method from PathUtil: 01102 DocCoord CubicMidpoint = PathUtil::PointOnCurve ( 0.5f, &Start ); 01103 01104 // Compare the values: 01105 DocCoord Difference = CubicMidpoint - QuadMidpoint; 01106 01107 // Originally I was using CalculateLength here, but there were some problems 01108 // with it, so I've effectively inlined the code from that function, and now 01109 // it seems to be running properly. I suspect that the problem was that when 01110 // an indefinate value is returned, the INT32 would be set as a strange value, 01111 // which caused problems for the if... statement below. 01112 double Distance = sqrt ( double( Difference.x * Difference.x ) 01113 + double( Difference.y * Difference.y ) ); 01114 01115 // I've been having trouble with values of Distance where it's an infinite value, 01116 // which Visual C stores as -1.#IND. This should keep it under control 01117 if ( ( Distance < Tolerance ) && ( Distance >= 0 ) ) 01118 { 01119 WriteCurveTo ( Start, Control, End ); 01120 return TRUE; 01121 } 01122 } 01123 01124 // If you get here, there's been a problem with rendering the curve. Therefore 01125 // split it in half, and attempt to write each half out to a flash file. 01126 PathVerb OutVerbs [6]; // Unused. 01127 DocCoord OutCoords [7]; 01128 UINT32 Points; 01129 01130 if ( PathUtil::SplitCurve ( 0.5f, &Start, &Points, OutVerbs, OutCoords + 1 ) ) 01131 { 01132 // Since I'm using references, I need to make a copy of Start for the 01133 // recursive call to work. Otherwise the program spins into an 01134 // infinite loop. 01135 OutCoords [0] = Start; 01136 01137 // Split curve, so recursively call ExportCurve. 01138 ExportCurve ( OutCoords [0], OutCoords [1], 01139 OutCoords [2], OutCoords [3], 01140 Tolerance ); 01141 01142 ExportCurve ( OutCoords [3], OutCoords [4], 01143 OutCoords [5], OutCoords [6], 01144 Tolerance ); 01145 } 01146 else 01147 { 01148 // We've got a problem! Render the curve as a straight line. 01149 WriteLineTo ( Start, End ); 01150 } 01151 01152 return TRUE; 01153 }
|
|
|
Calls ExportDC::Init ().
Reimplemented from ExportDC. Definition at line 206 of file swfexpdc.cpp. 00207 { 00208 if ( pFile == NULL ) 00209 { 00210 return FALSE; 00211 } 00212 00213 return ExportDC::Init ( pFile ); 00214 }
|
|
||||||||||||
|
Determines which kind of fill is being used, and takes appropriate action.
Definition at line 1237 of file swfexpdc.cpp. 01239 { 01240 BYTE Fill = pShape->GetFill (); 01241 01242 // Write in the fill type. 01243 WriteByte ( 1 ); // The number of fills. 01244 WriteByte ( Fill ); // The fill style. 01245 01246 // Use a switch to determine the correct fill processing routine to use. 01247 switch ( Fill ) 01248 { 01249 case FLASH_LINEAR_FILL: case FLASH_RADIAL_FILL: 01250 WriteGradientFill ( pShape, MoveTo ); 01251 break; 01252 01253 case FLASH_TILED_BITMAP: case FLASH_CLIPPED_BITMAP: 01254 WriteBitmapFill ( pShape, MoveTo ); 01255 break; 01256 01257 default: 01258 // Process as a linear fill. 01259 WriteColour ( pShape->GetColour ( 0 ) ); 01260 break; 01261 } 01262 01263 return TRUE; 01264 }
|
|
||||||||||||
|
Parses through the list of sprites, and replaces any records containing a single shape with a direct reference to the shape in the relevant button record. If the sprite record contains multiple shapes, then it is written out to disk directly.
Definition at line 2928 of file swfexpdc.cpp. 02930 { 02931 // Step 1: Declare local variables. 02932 INT32 Count = 0; 02933 FlashPlaceObject *pFirstPlace = pSprite->GetPlace (); 02934 FlashPlaceObject *pPlace = pFirstPlace; 02935 02936 // Step 2: Return FALSE if no button records have been passed in. This stops the 02937 // processing, and thus catches any errors. 02938 if ( pButton == NULL ) 02939 return FALSE; 02940 02941 // Step 2: Loop through the list, and count the number of FlashPlaceObject records 02942 // within the sprite record. 02943 while ( pPlace != NULL ) 02944 { 02945 Count ++; 02946 pPlace = pPlace->GetNext (); 02947 } 02948 02949 // Step 3a: If there is only one object within the sprite, spool through the button list, 02950 // and replace all references to sprites with those to objects. 02951 if ( Count == 1 ) 02952 { 02953 WORD SpriteID = pSprite->GetID (); 02954 WORD ShapeID = pFirstPlace->GetRawID (); 02955 FlashType Type = pFirstPlace->GetType (); 02956 DocCoord Position = pFirstPlace->GetPosition (); 02957 BOOL DoTransform = pFirstPlace->GetDoTransform (); 02958 02959 // Spool through the list of buttons, and match the sprite against all states. 02960 while ( pButton != NULL ) 02961 { 02962 // Check the hit state, and replace if necessary. 02963 if ( pButton->GetHitType () == FLASH_SPRITE ) 02964 { 02965 WORD ID = pButton->GetRawHitID (); 02966 02967 if ( ID == SpriteID ) 02968 { 02969 // Change the state's contents. 02970 pButton->SetHitID ( ShapeID, Type ); 02971 pButton->SetHitPosition ( Position, DoTransform ); 02972 } 02973 else if ( ID > SpriteID ) 02974 { 02975 // Reduce the ID value for future sprites, so that there are no gaps in 02976 // the ID numbers. 02977 pButton->SetHitID ( ID - 1, FLASH_SPRITE ); 02978 } 02979 } 02980 02981 // Check the down state, and replace if necessary. 02982 if ( pButton->GetDownType () == FLASH_SPRITE ) 02983 { 02984 WORD ID = pButton->GetRawDownID (); 02985 02986 if ( ID == SpriteID ) 02987 { 02988 // Change the state's contents. 02989 pButton->SetDownID ( ShapeID, Type ); 02990 pButton->SetDownPosition ( Position, DoTransform ); 02991 } 02992 else if ( ID > SpriteID ) 02993 { 02994 // Reduce the ID value for future sprites, so that there are no gaps in 02995 // the ID numbers. 02996 pButton->SetDownID ( ID - 1, FLASH_SPRITE ); 02997 } 02998 } 02999 03000 // Check the over state, and replace if necessary. 03001 if ( pButton->GetOverType () == FLASH_SPRITE ) 03002 { 03003 WORD ID = pButton->GetRawOverID (); 03004 03005 if ( ID == SpriteID ) 03006 { 03007 // Change the state's contents. 03008 pButton->SetOverID ( ShapeID, Type ); 03009 pButton->SetOverPosition ( Position, DoTransform ); 03010 } 03011 else if ( ID > SpriteID ) 03012 { 03013 // Reduce the ID value for successive sprites, so that there are no gaps 03014 // in the ID numbers. 03015 pButton->SetOverID ( ID - 1, FLASH_SPRITE ); 03016 } 03017 } 03018 03019 // Check the up state, and replace if necessary. 03020 if ( pButton->GetUpType () == FLASH_SPRITE ) 03021 { 03022 WORD ID = pButton->GetRawUpID (); 03023 03024 if ( ID == SpriteID ) 03025 { 03026 // Change the state's contents. 03027 pButton->SetUpID ( ShapeID, Type ); 03028 pButton->SetUpPosition ( Position, DoTransform ); 03029 } 03030 else if ( ID > SpriteID ) 03031 { 03032 // Reduce the ID value for future sprites, so that there are no gaps in 03033 // the ID numbers. 03034 pButton->SetUpID ( ID - 1, FLASH_SPRITE ); 03035 } 03036 } 03037 03038 // Move onto the next button record. 03039 pButton = pButton->GetNext (); 03040 } 03041 03042 // Decrease the sprite count to indicate that an element has been removed. 03043 FlashPlaceObject::DecSpriteCount (); 03044 03045 // And parse through the sprite list from this point onwards, decreasing the ID 03046 // numbers of successive sprites. 03047 while ( pSprite = pSprite->GetNext (), pSprite != NULL ) 03048 { 03049 pSprite->SetID ( pSprite->GetID () - 1 ); 03050 } 03051 } 03052 03053 // Step 3b: Otherwise export the sprite using the WriteSprite method. 03054 else 03055 { 03056 WriteSprite ( pSprite ); 03057 } 03058 03059 return TRUE; 03060 }
|
|
|
Transforms the co-ordinates of Bounds from Camelot space into Flash space. The rectangle is resized so that lo is (0,0).
Definition at line 1324 of file swfexpdc.cpp. 01325 { 01326 // Calculate the new hi co-ordinates for the bounding box. 01327 INT32 HiX; 01328 INT32 HiY; 01329 INT32 dX = Bounds->hi.x - Bounds->lo.x; 01330 INT32 dY = Bounds->hi.y - Bounds->lo.y; 01331 01332 // Catch rounding errors. 01333 if ( ( dX % FLASH_SCALE ) > ( FLASH_SCALE / 2 ) ) 01334 { 01335 HiX= ( dX / FLASH_SCALE ) + 1; 01336 } 01337 else 01338 { 01339 HiX= dX / FLASH_SCALE; 01340 } 01341 01342 if ( ( dY % FLASH_SCALE ) > ( FLASH_SCALE / 2 ) ) 01343 { 01344 HiY= ( dY / FLASH_SCALE ) + 1; 01345 } 01346 else 01347 { 01348 HiY= dY / FLASH_SCALE; 01349 } 01350 01351 // And write them into the data structure. 01352 Bounds->lo.x = 0; 01353 Bounds->lo.y = 0; 01354 Bounds->hi.x = HiX; 01355 Bounds->hi.y = HiY; 01356 }
|
|
||||||||||||
|
Transforms the co-ordinates of Point from Camelot space into Flash space. It's really a hack to replace the transformation matrix, until I work out how to initialise that properly.
Definition at line 1281 of file swfexpdc.cpp. 01283 { 01284 // Catch rounding errors. 01285 if ( ( Point->x % FLASH_SCALE ) > ( FLASH_SCALE / 2 ) ) 01286 { 01287 Point->x = ( Point->x / FLASH_SCALE ) + 1; 01288 } 01289 else 01290 { 01291 Point->x = ( Point->x / FLASH_SCALE ); 01292 } 01293 01294 if ( ( Point->y % FLASH_SCALE ) > ( FLASH_SCALE / 2 ) ) 01295 { 01296 Point->y = - ( Point->y / FLASH_SCALE ) - 1; 01297 } 01298 else 01299 { 01300 Point->y = - ( Point->y / FLASH_SCALE ); 01301 } 01302 01303 // If any transforms have been passed in... 01304 if ( MoveTo != NULL ) 01305 { 01306 Point->x -= MoveTo->x; 01307 Point->y += MoveTo->y; 01308 } 01309 }
|
|
||||||||||||
|
Forms a wrapper around all disk writes, with a small degree of error checking.
Definition at line 568 of file swfexpdc.cpp. 00570 { 00571 // I'm assuming that CCFile will return a NULL pointer if it fails, and this can be 00572 // caught by this code. 00573 if ( ExportFile->write ( Value, Size ) == NULL ) 00574 return FALSE; 00575 else 00576 return TRUE; 00577 }
|
|
||||||||||||||||
|
Writes out a Zlib compressed bitmap record to the Flash file.
Definition at line 1775 of file swfexpdc.cpp. |