2,275
社区成员
发帖
与我相关
我的任务
分享
StretchDIBits(
hdcVideo, rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
0, 0, pBitMapInfo->bmiHeader.biWidth, pBitMapInfo->bmiHeader.biHeight,
pBuf,
(BITMAPINFO*)pBitMapInfo,
DIB_RGB_COLORS,
SRCCOPY );
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()">
<fx:Script>
<![CDATA[
import flash.display.BitmapData;
import flash.net.Socket;
import com.adobe.images.JPGEncoder;
private var socket:Socket;
//初始化 8080端口发送socket数据
private function init():void {
socket = new Socket();
socket.addEventListener(ProgressEvent.SOCKET_DATA,
readSocketData);
socket.connect("127.0.0.1", 5555);
var timer:Timer = new Timer(20);
timer.addEventListener(TimerEvent.TIMER, function(e:Event):void{
SendVideo();
});
var cam:Camera = Camera.getCamera();
cam.setMode(400,300,30);
idVideoDisplay.attachCamera( cam ) ;
timer.start();
}
private function readSocketData(progressEvent:ProgressEvent):void
{
trace(progressEvent.bytesLoaded);
var ba:ByteArray = new ByteArray();
trace(socket.readBytes(ba));
}
private var imageSource:BitmapData= new BitmapData(400,300);
public function SendVideo():void
{
var matrix:Matrix=new Matrix();
var bytes:ByteArray;
imageSource.draw(idVideoDisplay,matrix);
bytes = imageSource.getPixels(imageSource.rect);//得到位图二进制数据
socket.writeBytes(bytes);
socket.flush();
}
]]>
</fx:Script>
<mx:VideoDisplay x="5" y="10" width="390" height="296" id="idVideoDisplay"/>
</s:Application>