| Autor | Zpráva | ||
|---|---|---|---|
| DarkKnight Profil |
#1 · Zasláno: 4. 3. 2013, 21:07:41
Zdravím,
vytvářím stránku, kde nutně potřebuji ukládat obrázky plátna. Nevím jestli vůbec je kód na nahrávání ve scriptu, ale pokud jo doufám, že bude pasovat do kódu který potřebuji... <html>
<head>
<title>toDataURL example</title>
<script type="text/javascript">
function draw() {
// Create some graphics.
var canvas = document.getElementById("MyCanvas");
if (canvas.getContext) {
var ctx = canvas.getContext("2d");
ctx.fillStyle = "white";
ctx.beginPath();
ctx.rect(5, 5, 300, 250);
ctx.fill();
ctx.stroke();
ctx.arc(150, 150, 100, 0, Math.PI, false);
ctx.stroke();
}
}
function putImage() {
var canvas1 = document.getElementById("MyCanvas");
if (canvas1.getContext) {
var ctx = canvas1.getContext("2d"); // Get the context for the canvas.
var myImage = canvas1.toDataURL("image/png"); // Get the data as an image.
}
var imageElement = document.getElementById("MyPix"); // Get the img object.
document.getElementById("MyPix");
imageElement.src = myImage; // Set the src to data from the canvas.
}
</script>
</head>
<body onload="draw()" >
<div>
<button onclick="putImage()">Copy graphic using toDataURL</button>
</div>
<div>
<canvas id="MyCanvas" width="400" height="400" >This browser or document mode doesn't support canvas</canvas>
<img id="MyPix" />
</div>
</body>
</html> Předem díky... |
||
| peta Profil |
#2 · Zasláno: 5. 3. 2013, 11:03:49
Ja mam ve ff udelanou takovouhle galerii. Obrazek je mozne presunout mysi z plochy, jineho webu nebo stejne stranky.
http://axpsu.fpf.slu.cz/~web/gal-pokus/gal-pokus.htm |
||
|
Časová prodleva: 14 let
|
|||
0