A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] Resizing of captured image via webcam

  1. #1
    Registered User
    Join Date
    Jan 2014
    Posts
    3

    resolved [RESOLVED] Resizing of captured image via webcam

    Hello
    I am new to actionscript. I want smaller size of captured image via webcam but I am confused where I

    have to edit in the below code to change the captured image. Now the image size is is 320x240 I need

    the images of size 185x240 (wxh). Any help on this is welcome.


    Here is the code -
    Code:
    package take_picture_fla
    {
        import com.adobe.images.*;
        import flash.display.*;
        import flash.events.*;
        import flash.media.*;
        import flash.net.*;
        import flash.ui.*;
        import flash.utils.*;
    
        dynamic public class MainTimeline extends MovieClip
        {
            public var capture_mc:MovieClip;
            public var bitmap:Bitmap;
            public var rightClickMenu:ContextMenu;
            public var snd:Sound;
            public var video:Video;
            public var bitmapData:BitmapData;
            public var warn:MovieClip;
            public var save_mc:MovieClip;
            public var bandwidth:int;
            public var copyright:ContextMenuItem;
            public var cam:Camera;
            public var quality:int;
    
            public function MainTimeline()
            {
                addFrameScript(0, frame1);
                return;
            }// end function
    
            public function onSaveJPG(event:Event) : void
            {
                var myEncoder:JPGEncoder;
                var byteArray:ByteArray;
                var header:URLRequestHeader;
                var saveJPG:URLRequest;
                var urlLoader:URLLoader;
                var sendComplete:Function;
                var e:* = event;
                sendComplete = function (event:Event) : void
                {
                    warn.visible = true;
                    addChild(warn);
                    warn.addEventListener(MouseEvent.MOUSE_DOWN, warnDown);
                    warn.buttonMode = true;
                    return;
                }// end function
                ;
                myEncoder = new JPGEncoder(100);
                byteArray = myEncoder.encode(bitmapData);
                header = new URLRequestHeader("Content-type", "application/octet-stream");
                saveJPG = new URLRequest("save.php");
                saveJPG.requestHeaders.push(header);
                saveJPG.method = URLRequestMethod.POST;
                saveJPG.data = byteArray;
                urlLoader = new URLLoader();
                urlLoader.addEventListener(Event.COMPLETE, sendComplete);
                urlLoader.load(saveJPG);
                return;
            }// end function
    
            public function warnDown(event:MouseEvent) : void
            {
                navigateToURL(new URLRequest("images/"), "_blank");
                warn.visible = false;
                return;
            }// end function
    
            function frame1()
            {
                stage.align = StageAlign.TOP_LEFT;
                stage.scaleMode = StageScaleMode.NO_SCALE;
                rightClickMenu = new ContextMenu();
                copyright = new ContextMenuItem("Developed By www.webinfopedia.com Go to Application");
                copyright.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, myLink);
                copyright.separatorBefore = false;
                rightClickMenu.hideBuiltInItems();
                rightClickMenu.customItems.push(copyright);
                this.contextMenu = rightClickMenu;
                snd = new camerasound();
                bandwidth = 0;
                quality = 100;
                cam = Camera.getCamera();
                cam.setQuality(bandwidth, quality);
                cam.setMode(320, 240, 30, false);
                video = new Video();
                video.attachCamera(cam);
                video.x = 20;
                video.y = 20;
                addChild(video);
                bitmapData = new BitmapData(video.width, video.height);
                bitmap = new Bitmap(bitmapData);
                bitmap.x = 360;
                bitmap.y = 20;
                addChild(bitmap);
                capture_mc.buttonMode = true;
                capture_mc.addEventListener(MouseEvent.CLICK, captureImage);
                save_mc.alpha = 0.5;
                warn.visible = false;
                return;
            }// end function
    
            public function captureImage(event:MouseEvent) : void
            {
                snd.play();
                bitmapData.draw(video);
                save_mc.buttonMode = true;
                save_mc.addEventListener(MouseEvent.CLICK, onSaveJPG);
                save_mc.alpha = 1;
                return;
            }// end function
    
            public function myLink(event:Event)
            {
                navigateToURL(new URLRequest("http://www.webinfopedia.com/export-database-data-to-excel-
    
    in-php.html"), "_blank");
                return;
            }// end function
    
        }
    }
    Thank you everybody in advance for guidance and suggestion

  2. #2
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    This is AS2 forum, not AS3. But try this:

    I think in the frame1 function, below bitmap.x = 360; bitmap.y = 20;

    add: bitmap.width = 185; bitmap.height = 240;
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  3. #3
    Registered User
    Join Date
    Jan 2014
    Posts
    3
    Thank you it works

  4. #4
    Junior Member
    Join Date
    Jul 2013
    Posts
    22
    One easy way to resizing the captured image from webcam is to save the image into local file, embed it to the image resizer of image handler, then apply image resizing function to resize the image width and heigth.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center