Webcam snapshot saved size problem

hello there,

i’m having a strange problem when running a snapshot script from a webcam using the jpegencode function.
when I hit the button that takes the pictures, the size correct, but when I check my uploaded picture and display it, it’s small, aligned on top left and filled with white around.
I don’t get why.
Here is the code used :


var cam:Camera = Camera.getCamera();
cam.setMode(320,240, 24, true);
cam.setQuality(0,100);
if (cam.muted) {
    Security.showSettings(SecurityPanel.DEFAULT);
}

video.attachCamera(cam);
bouton_btn.addEventListener("click",prendrePhoto);

function getBitmapData( target : Video ):BitmapData {
    var bd : BitmapData = new BitmapData (400, 300, false);
    var m : Matrix = new Matrix();
    bd.draw(target, target.transform.matrix);
    return bd;
}
function prendrePhoto(e:MouseEvent):void {
    var jpgSource:BitmapData = new BitmapData (320,240);
    jpgSource.draw(video);
    var bm_video:Bitmap = new Bitmap(jpgSource);
    image1_mc.addChild(bm_video);
    var jpgEncoder:JPGEncoder = new JPGEncoder(99);
    var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);
    var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
    var jpgURLRequest:URLRequest = new URLRequest("upload.php?filename="+filename);
    jpgURLRequest.requestHeaders.push(header);
    jpgURLRequest.method = URLRequestMethod.POST;
    jpgURLRequest.data = jpgStream;
    var loader:URLLoader = new URLLoader();
    loader.addEventListener(Event.COMPLETE, uploadCompleted);
    loader.load(jpgURLRequest);

}
function uploadCompleted(e:Object):void {
    trace("uploaded finisehd");
}



Mabny thanks !!