2013-02-23 65 views
1

我正在Adobe AIR中爲iOS開發遊戲,並且想要截取屏幕截圖(或屏幕的特定部分/影片剪輯的位圖捕獲)。我讀過使用本機擴展獲取屏幕截圖的可能性,但實際上並不需要整個屏幕,我只需要在Adobe AIR中使用特定影片剪輯的位圖表示(如果可能)。我不認爲我需要訪問本機SDK來實現這一目標,但我找不到任何資源來實現我正在嘗試做的事情。在Adobe AIR中將特定的影片剪輯寫入位圖

如何使用本機擴展在Adobe AIR中保存影片剪輯的「位圖快照」,而不使用

謝謝,

可以。

+0

影片剪輯與.swf或.mp4一樣嗎? – Kevin 2013-02-23 14:36:12

+0

像在swf中一樣flash flash movieclip對象。 – 2013-02-23 14:57:57

回答

1

如果你只需要內容的快照從您的AIR應用程序中,你可以使用的BitmapData的draw()方法(例如影片剪輯/其他的DisplayObject):

/* 
* getSnapshot - simple snapshot of a DisplayObject 
* @param matrix - the transformation matrix of the object to be drawn(translation/rotation/scale) 
*     use this parameter to include the object's tranformations or an arbitrary one. 
*     Ex. getSnapshot(myClip,myClip.transform.concatenatedMatrix); 
* @param coordinateSpace - the coordinate space from used to get bounds. if you're object's rotated, 
*       the by passing null, the bitmap will include all contents, otherwise it will be 
*       clipped using the original/'unrotated' bounds. 
*/ 
function getSnapshot(obj:DisplayObject,matrix:Matrix = null,coordinateSpace:DisplayObject = null):BitmapData{ 
    var bounds:Rectangle = obj.getBounds(coordinateSpace); 
    var result:BitmapData = new BitmapData(bounds.width,bounds.height,true,0x00FFFFFF); 
    result.draw(obj,matrix); 
    return result; 
} 

例如

var test:Shape = addChild(new Shape()) as Shape; 
test.graphics.beginFill(0);test.graphics.drawRect(0,0,100,100);test.graphics.endFill(); 

var snapShot:Bitmap = addChild(new Bitmap(getSnapshot(test))) as Bitmap; 
snapShot.x = test.width+10; 

function getSnapshot(obj:DisplayObject,matrix:Matrix = null,coordinateSpace:DisplayObject = null):BitmapData{ 
    var bounds:Rectangle = obj.getBounds(coordinateSpace); 
    var result:BitmapData = new BitmapData(bounds.width,bounds.height,true,0x00FFFFFF); 
    result.draw(obj,matrix); 
    return result; 
} 
+0

位圖數據工作得很好,正是我所需要的。 – 2013-02-27 11:28:19