VideoTexture 贴图

时间:2021-07-20 22:24:22

//old
bitmapData.lock();
bitmapData.fillRect(_clippingRect, 0);
bitmapData.draw(_player.container, null, null, null, _clippingRect);
bitmapData.unlock();
invalidateContent();

//新Api

if (_player.playing && !_player.paused) {

var graphicsData : Vector.<IGraphicsData>;
graphicsData = _player.container.graphics.readGraphicsData();
if ( graphicsData.length > 0 ) {

if(bitmapData){
bitmapData.dispose();
}
bitmapData = GraphicsBitmapFill(graphicsData[0]).bitmapData;
trace("bitmapData::",bitmapData.width,bitmapData.height);
invalidateContent();
}

}

////矩阵缩放

var graphicsData : Vector.<IGraphicsData>;
graphicsData =_videoContainer.graphics.readGraphicsData();
if ( graphicsData.length > 0 ) {
var bitmapObj:BitmapData = GraphicsBitmapFill(graphicsData[0]).bitmapData;
var matrix:Matrix = new Matrix();
matrix.scale(bitmapData.width/bitmapObj.width,bitmapData.height/bitmapObj.height);
bitmapData.lock();
bitmapData.draw(bitmapObj,matrix);
trace("视频原始尺寸::",bitmapObj.width,bitmapObj.height,bitmapObj);
bitmapData.unlock();
}

graphicsData = _player.container.graphics.readGraphicsData();
if ( graphicsData.length > 0 ) {

bitmapObj = GraphicsBitmapFill(graphicsData[0]).bitmapData;

var matrix:Matrix = new Matrix();
matrix.scale(bitmapData.width/bitmapObj.width,bitmapData.height/bitmapObj.height);
bitmapData.lock();
bitmapData.draw(bitmapObj,matrix);
// trace("视频原始尺寸::",bitmapObj.width,bitmapObj.height,bitmapObj);
bitmapData.unlock();
}
// trace("标准尺寸::",bitmapData.width,bitmapData.height);
invalidateContent();
}