1

I am writing a MovieClip rasterizer which rasterizes all the frames in the specified movieclip. Here's the code for rasterizing:

for ( var i:int = start; i <= end; i++ )
{
 //goto the next frame
 clip.gotoAndStop( i );

//get the bounds bounds = clip.getBounds(clip);

//create a new bitmapdata container bitmapData = new BitmapData( transformer.width == -1 ? bounds.width : transformer.width, transformer.height == -1 ? bounds.height : transformer.height, transformer.transparent, transformer.color );

if (transformer.matrix.tx == 0 && transformer.matrix.ty == 0) transformer.translateToZero( bounds );

//draw the bitmap data with the transformers bitmapData.draw( this._source, transformer.matrix, transformer.colorTransform, transformer.blendMode, transformer.clipRect, //new Rectangle(0, 0, bounds.width, bounds.height), transformer.smoothing );

//push the data on the array frames.push( bitmapData ); }

Now the result is different - http://i42.tinypic.com/lfv52.jpg - the black one is the rasterized version ( i used a color transform on it to test it :P). Note the head and left shoe. Anyone knows what the problem is? I've seen people adding 'extra' pixels to their boundary box at the BitmapData constructor, but thats the right solution.

Anyone got an idea how to fit in the character nicely?

Fristi
  • 13
  • 5

1 Answers1

0

You didn't say what transformer.translateToZero() does but, are you sure the character is always aligned at (0, 0)?

I mean, you should pass bounds as BitmapData.draw()'s clipRect argument if you wanted it to copy the whole MovieClip.

mrkishi
  • 5,602
  • 1
  • 20
  • 18
  • translateToZero does this: _matrix.translate( -bounds.x, -bounds.y ); //_matrix = flash.geom.Matrix It inverses the current x and y axis of the movieclip to zero. If i pass the bounds to the clipRect of the BitmapData.draw method 1/4 of the movieclip is drawn since the the movieclip is centered. – Fristi Mar 14 '10 at 11:56