# JpgEncoder saves me white jpg ? why?

**URL:** <https://forum.kirupa.com/t/jpgencoder-saves-me-white-jpg-why/291779>\
**Category:** Uncategorized\
**Created:** [July 5, 2009, 3:13pm UTC](https://forum.kirupa.com/t/jpgencoder-saves-me-white-jpg-why/291779 "2009-07-05T15:13:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![humbucker](https://avatars.discourse-cdn.com/v4/letter/h/278dde/32.png) [@humbucker](https://forum.kirupa.com/u/humbucker)\
**Post date:** [July 5, 2009, 3:13pm UTC](https://forum.kirupa.com/t/jpgencoder-saves-me-white-jpg-why/291779/1 "2009-07-05T15:13:48Z")

</div>

Hello,

I’m using the jpgEncoder for a webcam snapshot app, my script was running right when my code was into my FLA on a layer, BUT I wanted to take it away in a document class, and now I’m having 2 issues :

a) when I shot a picture, the image doesnt stay frozen even with the line [attachCamera(null)]  
b) I get a white image saved on my server

Here is my code so far :

```auto

    public var jpgEncoder:JPGEncoder=new JPGEncoder(90);
    public var ba:ByteArray=null;
    public var cam:Camera=Camera.getCamera();
    public var retourVideo:Video=new Video();

```

```auto

private function addCam():void {

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

        var retourVideo:Video=new Video(515,386);//Video(cam.width, cam.height);
        retourVideo.attachCamera(cam);
        retourVideo.x = -150;
        retourVideo.y = 15;
        retourVideo.rotation =-3;    
        magMask.addChild(retourVideo);
    }

    public function snap(e:MouseEvent):void {
        var bmd:BitmapData=new BitmapData(retourVideo.width,retourVideo.height,false);
        bmd.draw(retourVideo,new Matrix());
        ba=jpgEncoder.encode(bmd);

        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=ba;
        sendToURL(jpgURLRequest);

        snapAgain.visible=true;
        snapNow.visible=false;
        BoSnap=true;
        
        retourVideo.attachCamera(null);
    }

    
    public function retake(e:MouseEvent):void {
        retourVideo.attachCamera(cam);
        snapAgain.visible=false;
        snapNow.visible=true;
        BoSnap=false;
    }

```

Can you please look at my code and help me ?

Thanks :bu:
