[Geesas-Devs] SF.net SVN: geesas:[16] pencilanimation/src/external/flash
Status: Abandoned
Brought to you by:
creek23
From: <cr...@us...> - 2009-02-09 23:22:54
|
Revision: 16 http://geesas.svn.sourceforge.net/geesas/?rev=16&view=rev Author: creek23 Date: 2009-02-09 22:25:31 +0000 (Mon, 09 Feb 2009) Log Message: ----------- changed SWFSprite to SWFMovieClip. implicit usage of SWFFILL_CLIPPED_BITMAP, default is SWFFILL_TILED_BITMAP. added Fill scaling to fit the Shape. Modified Paths: -------------- pencilanimation/src/external/flash/flash.cpp pencilanimation/src/external/flash/flash.h Modified: pencilanimation/src/external/flash/flash.cpp =================================================================== --- pencilanimation/src/external/flash/flash.cpp 2009-02-09 17:32:40 UTC (rev 15) +++ pencilanimation/src/external/flash/flash.cpp 2009-02-09 22:25:31 UTC (rev 16) @@ -36,7 +36,7 @@ movie->setRate(fps); // 12 frames per seconds //SWFShape *shape = new SWFShape(); - SWFSprite *objectSprite = new SWFSprite(); + SWFMovieClip *objectMovieClip = new SWFMovieClip(); for(int i=0; i < object->getLayerCount(); i++) { Layer* layer = object->getLayer(i); @@ -44,50 +44,50 @@ // paints the bitmap images if(layer->type == Layer::BITMAP) { LayerBitmap* layerBitmap = (LayerBitmap*)layer; - SWFSprite *layerSprite = new SWFSprite(); + SWFMovieClip *layerMovieClip = new SWFMovieClip(); SWFDisplayItem *previousItem = NULL; for(int frameNumber = startFrame; frameNumber <= endFrame; frameNumber++) { BitmapImage* bitmapImage = layerBitmap->getBitmapImageAtFrame(frameNumber); if(bitmapImage != NULL) { - if(previousItem != NULL) layerSprite->remove( previousItem ); - SWFSprite *imageSprite = new SWFSprite(); - convertToSWFSprite( bitmapImage, object, view, imageSprite); - previousItem = layerSprite->add( imageSprite ); + if(previousItem != NULL) layerMovieClip->remove( previousItem ); + SWFMovieClip *imageMovieClip = new SWFMovieClip(); + convertToSWFMovieClip( bitmapImage, object, view, imageMovieClip); + previousItem = layerMovieClip->add( imageMovieClip ); } - layerSprite->nextFrame(); + layerMovieClip->nextFrame(); } - //layerSprite->add( new SWFAction("stop();") ); - //layerSprite->nextFrame(); - objectSprite->add(layerSprite); + //layerMovieClip->add( new SWFAction("stop();") ); + //layerMovieClip->nextFrame(); + objectMovieClip->add(layerMovieClip); } // paints the vector images if(layer->type == Layer::VECTOR) { LayerVector* layerVector = (LayerVector*)layer; - SWFSprite *layerSprite = new SWFSprite(); + SWFMovieClip *layerMovieClip = new SWFMovieClip(); SWFDisplayItem *previousItem = NULL; for(int frameNumber = startFrame; frameNumber <= endFrame; frameNumber++) { VectorImage* vectorImage = layerVector->getVectorImageAtFrame(frameNumber); if(vectorImage != NULL) { - if(previousItem != NULL) layerSprite->remove( previousItem ); - SWFSprite *sprite = new SWFSprite(); - convertToSWFSprite( vectorImage, object, view, sprite); - previousItem = layerSprite->add( sprite ); + if(previousItem != NULL) layerMovieClip->remove( previousItem ); + SWFMovieClip *movieClip = new SWFMovieClip(); + convertToSWFMovieClip( vectorImage, object, view, movieClip); + previousItem = layerMovieClip->add( movieClip ); } - layerSprite->nextFrame(); + layerMovieClip->nextFrame(); } - //layerSprite->add( new SWFAction("stop();") ); - //layerSprite->nextFrame(); + //layerMovieClip->add( new SWFAction("stop();") ); + //layerMovieClip->nextFrame(); - objectSprite->add(layerSprite); + objectMovieClip->add(layerMovieClip); } } } - objectSprite->nextFrame(); - //objectSprite->add( new SWFAction("stop();") ); - //objectSprite->nextFrame(); + objectMovieClip->nextFrame(); + //objectMovieClip->add( new SWFAction("stop();") ); + //objectMovieClip->nextFrame(); - movie->add(objectSprite); + movie->add(objectMovieClip); movie->nextFrame(); movie->add( new SWFAction("gotoFrame(0);") ); movie->nextFrame(); @@ -100,33 +100,37 @@ } -void Flash::convertToSWFSprite( BitmapImage* bitmapImage, Object* object, QMatrix view, SWFSprite* sprite ) { +void Flash::convertToSWFMovieClip( BitmapImage* bitmapImage, Object* object, QMatrix view, SWFMovieClip* movieClip ) { QString tempPath = QDir::tempPath()+"/penciltemp.png"; - QByteArray tempPath2( tempPath.toLatin1()); - bitmapImage->image->save( tempPath , "PNG"); + QByteArray tempPath2( tempPath.toLatin1()); + bitmapImage->image->save( tempPath , "PNG",100); SWFShape *shape = new SWFShape(); - SWFFill* fill = shape->addBitmapFill( new SWFBitmap( tempPath2.data() ) ); - fill->moveTo(static_cast<float>(bitmapImage->topLeft().x()), static_cast<float>(bitmapImage->topLeft().y())); - shape->setRightFill(fill); - shape->movePenTo(bitmapImage->left(), bitmapImage->top()); - shape->drawLineTo(bitmapImage->right(), bitmapImage->top()); - shape->drawLineTo(bitmapImage->right(), bitmapImage->bottom()); - shape->drawLineTo(bitmapImage->left(), bitmapImage->bottom()); - shape->drawLineTo(bitmapImage->left(), bitmapImage->top()); - SWFDisplayItem *item = sprite->add( shape ); - //item->setMatrix( view.m11(), view.m12(), view.m21(), view.m22(), view.dx(), view.dy() ); // this C++ method is not defined in mingpp.h version 0.3 - SWFDisplayItem_setMatrix( item->item, view.m11(), view.m12(), view.m21(), view.m22(), view.dx(), view.dy() ); // we use the C function instead - sprite->nextFrame(); + SWFFill *fill = shape->addBitmapFill(new SWFBitmap(tempPath2),SWFFILL_CLIPPED_BITMAP); + fill->moveTo(static_cast<float>(bitmapImage->topLeft().x()), static_cast<float>(bitmapImage->topLeft().y())); + fill->scaleX(20); + fill->scaleY(20); + shape->setRightFill(fill); + shape->movePenTo(bitmapImage->left(), bitmapImage->top()); + shape->drawLineTo(bitmapImage->right(), bitmapImage->top()); + shape->drawLineTo(bitmapImage->right(), bitmapImage->bottom()); + shape->drawLineTo(bitmapImage->left(), bitmapImage->bottom()); + shape->drawLineTo(bitmapImage->left(), bitmapImage->top()); + SWFDisplayItem *item = movieClip->add( shape ); + //for Ming 0.4.0 + item->setMatrix( view.m11(), view.m12(), view.m21(), view.m22(), view.dx(), view.dy() ); + //for Ming 0.3.0 + //SWFDisplayItem_setMatrix( item->item, view.m11(), view.m12(), view.m21(), view.m22(), view.dx(), view.dy() ); + movieClip->nextFrame(); } -void Flash::convertToSWFSprite( VectorImage* vectorImage, Object* object, QMatrix view, SWFSprite* sprite ) { +void Flash::convertToSWFMovieClip( VectorImage* vectorImage, Object* object, QMatrix view, SWFMovieClip* movieClip ) { // add filled areas for(int i=0; i< vectorImage->area.size(); i++) { QColor colour = object->getColour(vectorImage->area[i].getColourNumber()).colour; QPainterPath path = view.map( vectorImage->area[i].path ); - addShape(sprite, path, colour, colour, 0, true); + addShape(movieClip, path, colour, colour, 0, true); } // add curves for(int i=0; i< vectorImage->curve.size(); i++) { @@ -134,21 +138,21 @@ QColor colour = object->getColour(vectorImage->curve[i].getColourNumber()).colour; if(vectorImage->curve[i].getVariableWidth()) { QPainterPath path = view.map( vectorImage->curve[i].getStrokedPath() ); - addShape(sprite, path, colour, colour, 0, true); + addShape(movieClip, path, colour, colour, 0, true); } else { QPainterPath path = view.map( vectorImage->curve[i].getSimplePath() ); qreal width = vectorImage->curve[i].getWidth(); - addShape(sprite, path, colour, colour, width, false); + addShape(movieClip, path, colour, colour, width, false); } } } - sprite->nextFrame(); + movieClip->nextFrame(); } -void Flash::addShape( SWFSprite* sprite, QPainterPath path, QColor fillColour, QColor borderColour, qreal width, bool fill ) { +void Flash::addShape( SWFMovieClip* movieClip, QPainterPath path, QColor fillColour, QColor borderColour, qreal width, bool fill ) { SWFShape* shape = new SWFShape(); //float widthf = static_cast< float >(width); if(width == 0.0) { @@ -232,5 +236,5 @@ memoP1y = element.y; } } - sprite->add( shape ); + movieClip->add( shape ); } Modified: pencilanimation/src/external/flash/flash.h =================================================================== --- pencilanimation/src/external/flash/flash.h 2009-02-09 17:32:40 UTC (rev 15) +++ pencilanimation/src/external/flash/flash.h 2009-02-09 22:25:31 UTC (rev 16) @@ -33,9 +33,9 @@ { public: static void exportFlash(Object* object, int startFrame, int endFrame, QMatrix view, QSize exportSize, QString filePath, int fps, int compression); - static void convertToSWFSprite( BitmapImage* image, Object* object, QMatrix view, SWFSprite* sprite ); - static void convertToSWFSprite( VectorImage* vectorImage, Object* object, QMatrix view, SWFSprite* sprite ); - static void addShape( SWFSprite* sprite, QPainterPath path, QColor fillColour, QColor borderColour, qreal width, bool fill ); + static void convertToSWFMovieClip( BitmapImage* image, Object* object, QMatrix view, SWFMovieClip* movieClip ); + static void convertToSWFMovieClip( VectorImage* vectorImage, Object* object, QMatrix view, SWFMovieClip* movieClip ); + static void addShape( SWFMovieClip* movieClip, QPainterPath path, QColor fillColour, QColor borderColour, qreal width, bool fill ); }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |