canvas教程

ASP.NET Web HTML 5 绘画工具(2)

字号+ 作者:H5之家 来源:H5之家 2015-10-08 17:21 我要评论( )

//Save as Image filefunction ShanuSaveImage() {var m = confirm("Are you sure to Save ");if (m) {// generate the image datavar image_NEW = document.getElementById("canvas").toDataURL("image/png");imag

//Save as Image file function ShanuSaveImage() { var m = confirm("Are you sure to Save "); if (m) { // generate the image data var image_NEW = document.getElementById("canvas").toDataURL("image/png"); image_NEW = image_NEW.replace(´data:image/png;base64,´, ´´); $.ajax({ type: ´POST´, url: ´Default.aspx/SaveImage´, data: ´{ "imageData" : "´ + image_NEW + ´" }´, contentType: ´application/json; charset=utf-8´, dataType: ´json´, success: function (msg) { alert(´Image saved to your root Folder !´); } }); } } 这是Web方法在画布上的图像存储到根文件夹。

[WebMethod()] public static void SaveImage(string imageData) { Random rnd = new Random(); String Filename = HttpContext.Current.Server.MapPath("Shanuimg" + rnd.Next(12, 2000).ToString() + ".png"); string Pic_Path = Filename;//HttpContext.Current.Server.MapPath("ShanuHTML5DRAWimg.png"); using (FileStream fs = new FileStream(Pic_Path, FileMode.Create)) { using (BinaryWriter bw = new BinaryWriter(fs)) { byte[] data = Convert.FromBase64String(imageData); bw.Write(data); bw.Close(); } } } 与HTML5工作是很有趣。我希望你喜欢读我的文章。我会很高兴。

源码下载链接: ?bdkey=s/1hqDY0Pe 密码: fgwa

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • canvas使用注意点总结_html5教程技巧

    canvas使用注意点总结_html5教程技巧

    2016-12-22 14:01

  • HTML5 Canvas圆盘抽奖

    HTML5 Canvas圆盘抽奖

    2016-08-29 12:04

  • canvas使用注意点总结

    canvas使用注意点总结

    2015-10-17 15:05

  • HTML5教程:画布Canvas基础知识讲解

    HTML5教程:画布Canvas基础知识讲解

    2015-10-17 15:03

网友点评
a