2010-03-13 80 views
1

我正在寫一個MovieClip光柵化器,它將指定的動畫片段中的所有幀柵格化。下面是光柵化代碼:BitmapData截止

 
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); }

現在的結果是不同的 - http://i42.tinypic.com/lfv52.jpg - 黑色一個是光柵化版本(我用一種顏色的變換來測試它:P)。注意頭和左鞋。任何人都知道問題是什麼?我已經看到人們在BitmapData構造函數的邊界框中添加「額外」像素,但這是正確的解決方案。

任何人都有一個想法如何很好地適應角色?

回答

0

你沒有說什麼transformer.translateToZero()但是,你確定字符總是對齊在(0,0)嗎?

我的意思是,你應該通過範圍的的BitmapData.draw()clipRect說法,如果你想它來複制整個影片剪輯

+0

translateToZero執行此操作:_matrix.translate(-bounds.x,-bounds.y); // _ matrix = flash.geom.Matrix 它將動畫片段的當前x軸和y軸倒轉爲零。如果我將界限傳遞給BitmapData.draw方法的clipRect,則由於動畫片段居中,所以會繪製1/4的動畫片段。 – Fristi