<!doctype html>
<html lang="en">
<head>
<script type="text/javascript" src="jquery-1.8.3.min.js"></script>
<script src="js/canvas2image.js"></script>
<script src="js/base64.js"></script>
<script src="js/canvg.js"></script>
<script type="text/javascript">
function saveCanvas(pCanvas, strType) {
var bRes = false;
if (strType == "PNG")
bRes = Canvas2Image.saveAsPNG(pCanvas);
if (strType == "BMP")
bRes = Canvas2Image.saveAsBMP(oCanvas);
if (strType == "JPEG")
bRes = Canvas2Image.saveAsJPEG(oCanvas);
if (!bRes) {
alert("Sorry, this browser is not capable of saving " + strType + " files!");
return false;
}
}
function aa()
{
var svgHtml=document.getElementById("container").innerHTML.Trim();
var canvasId=document.getElementById("canvasId");
canvg(canvasId,svgHtml);
}
function a2(){
var ccc = document.getElementById("canvasId");
var imgsrc=document.getElementById("myImg");
var a=convertCanvasToImage(ccc).src;
imgsrc.src=a;
}
function a3(){
var oCanvas = document.getElementById("canvasId");
saveCanvas(oCanvas, "PNG");
}
// Converts canvas to an image
function convertCanvasToImage(canvas) {
var image = new Image();
image.src = canvas.toDataURL("image/png");
return image;
}
String.prototype.Trim = function () {
return this.replace(/(^\s*)|(\s*$)/g, "");
};
</script>
</head>
<body>
<input type="button" value="转化为canvas" onClick="aa()" />
<input type="button" value="转化为img" onClick="a2()" />
<input type="button" value="下载img" onClick="a3()" />
<div id="container" style="min-width:700px;height:400px">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect width="300" height="100" style="fill:rgb(50,50,200);stroke-width:1;stroke:rgb(0,0,0)" />
</svg>
</div>
<canvas id="canvasId" ></canvas>
<img src='' id='myImg' style="width:100%; height:400px;" />
</body>
</html>
l_0224
- 粉丝: 0
- 资源: 3
最新资源
- MATLAB(GUI)的人脸门禁【ORL人脸库,库外预警,可增删查】.zip
- 智能驾驶ADAS基础知识(一)
- MATLAB(GUI)的手写字符识别[数字,字母,符号].zip
- MATLAB(GUI)的小波变换dwt数字水印[彩色,评价指标,GUI框架].zip
- MATLAB(GUI)的水果识别分类(分类器,Matlab版运行).zip
- MATLAB(GUI)的语音滤波(FIR,多方法,GUI界面).zip
- Matlab Simulink模型代搭 七自由度整车动力学模型 魔术轮胎模型 轮毂电机模型 软件使用:Matlab Simulink 适用场景:整车动力学建模,Carsim与Simulink联合仿真验
- MATLAB(GUI)的运动行为检测(某行为预警).zip
- MATLAB(GUI)购物系统,无人自助购物(自动计费,历史购物清单查询,GUI框架).zip
- MATLAB(GUI)汉字识别(写字板,GUI界面).zip
- MATLAB(GUI)汉字语音识别(语音转汉字,GUI界面).zip
- MATLAB(GUI)火焰识别[创新点:Bp神经网络].zip
- Delphi 12 控件之GExperts-RS12-1.3.25-2024-08-24.exe
- MATLAB(GUI)火焰识别系统(创新点:面积增长率,面积高度).zip
- MATLAB(GUI)基于DWT+SVD结合傅里叶变换的数字图像水印水印系统(嵌入+攻击+提取).zip
- MATLAB(GUI)火焰烟雾检测(视频,有火焰则预警,GUI).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈