asp.net使用網路攝影機拍照

來源:互聯網
上載者:User

視頻拍照的flash檔案

import it.sephiroth.mloaderWindow
import it.sephiroth.PrintScreen

myCam = Camera.get();
myCam.setMode(390, 290, 10);
my_video.attachVideo(myCam);
var loader:mloaderWindow = this.createClassObject(mloaderWindow, "loader", 10, {_x:-1000, _y:-1000})
//loader.setStyle("borderColor", 0x006699)

var listener:Object = new Object();

listener.onProgress = function(target:MovieClip, loaded:Number, total:Number){
 var perc = Math.round((loaded/total)*100)
 loader.label = "Sending... " + perc + "%"
 loader.value = perc
}

listener.onComplete = function(target:MovieClip, load_var:LoadVars){
 loader.label = "Sending..."
 load_var.send("makepic.aspx", "_self", "POST")
 loader.close()
}

function print_me(){
 var mc_x = 15;
 var mc_y = 15;
 my_video.attachVideo(null);
 pn = new PrintScreen(); 
 pn.addListener( listener ); 
 pn.print(_root, 0, 0, 390, 290, mc_x, mc_y) 
 loader.label = "輸出中... 0%"
 loader.open(true, true, true); 
}

 

asp.net 擷取flash拍照程式的資料: 

private bool CreateImage(string Path)
    {

        int w = 0;
        int h = 0;

        try
        {
            w = int.Parse(Request.Form["width"]);
            h = int.Parse(Request.Form["height"]);
        }
        catch (Exception ee)
        {
            Response.Write(ee.Message);
            return false;
        }

        Bitmap newmap = new Bitmap(w, h);
        int rows = 0;
        int cols = 0;

        Graphics gp = Graphics.FromImage(newmap);
        gp.Clear(Color.White);
        ImageCodecInfo myImageCodecInfo;
        System.Drawing.Imaging.Encoder myEncoder;
        EncoderParameter myEncoderParameter;
        EncoderParameters myEncoderParameters;
        myImageCodecInfo = ImageCodecInfo.GetImageEncoders()[1];
        myEncoder = System.Drawing.Imaging.Encoder.Quality;
        myEncoderParameters = new EncoderParameters(1);
        myEncoderParameter = new EncoderParameter(myEncoder, 95L);
        myEncoderParameters.Param[0] = myEncoderParameter;

        gp.CompositingQuality = CompositingQuality.HighQuality;
        gp.SmoothingMode = SmoothingMode.HighQuality;
        gp.InterpolationMode = InterpolationMode.HighQualityBicubic;
        gp.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
        for (rows = 0; rows < newmap.Height; rows++) //循環圖表片高度
        {
            string px = Request["PX" + rows];
            string[] c_row = px.Split(',');
            for (cols = 0; cols < newmap.Width; cols++) //循環圖表片寬度
            {

                string values = c_row[cols];
                if (values != "" && values != null)
                {
                    string hex = values;
                    while (hex.Length < 6)
                    {//防止顏色丟失
                        hex = "0" + hex;
                    }

                    int r = int.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
                    int g = int.Parse(hex.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
                    int b = int.Parse(hex.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);

                    newmap.SetPixel(cols, rows, Color.FromArgb(r, g, b));

                }
            }
        }

        gp.DrawImage(newmap, 0, 0, w, h);
        Path = Server.MapPath("makepic.aspx")+"123.jpg";
        //儲存路徑,修改這裡
        newmap.Save(Path, myImageCodecInfo, myEncoderParameters);
        myEncoderParameters.Dispose();
        gp.Dispose();
        newmap.Dispose();
        Response.Redirect(Path);
        return true;
    } 

對flash不太瞭解釋從盟動力上下的一個flash源碼,使在php中調用的,此處改為在asp.net中調用

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.