Hello,
I'm developing an AIR application that takes an snapshot of my camera and upload it to my server.
I've got the following AS3 code:
viewer.smoothing =true;
viewer.deblocking =5;
viewer.attachCamera(cam);
cam.setQuality(0,100);
cam.setMode(1920, 1080,24);
cam.setKeyFrameInterval(10);
cam.setMotionLevel(100);
cam.setLoopback(false);
var bitmapData:BitmapData=newBitmapData(1920, 1080);
bitmapData.draw(viewer);
var jpg:JPGEncoder=newJPGEncoder();
var myBytes:ByteArray= jpg.encode(bitmapData);
var request:URLRequest=newURLRequest(urlToCall);
request.data = myBytes;
request.method =URLRequestMethod.POST;
var header:URLRequestHeader=newURLRequestHeader("Content-type","application/octet-stream");
request.requestHeaders.push(header);
var loader:URLLoader=newURLLoader();
loader.addEventListener(Event.COMPLETE, onCertificateComplete);
loader.load(request);
I've got the following C# code:
Stream rs =(Stream)context.Request.InputStream;
string destPath ="c:\\docs\\img.jpg";
FileStream fs =newFileStream(destPath,FileMode.Create);
byte[] byWork =newbyte[2047];
int iWork;
do
{
iWork = rs.Read(byWork,0, byWork.Length);
fs.Write(byWork,0, iWork);
}while(iWork !=0);
fs.Flush();
fs.Close();
rs.Close();
The problem is the resultant photo. It has a 1920x1080 canvas size, but my webcam image in the photo it's only 160x120px, and the other pixels are white.
What I'm doing wrong? My webcam accepts 1920x1080px of resolution. My viewer is a "Video" instance.
Could someone help me?
Kind regards