Solved

How to load a CANVAS from an image stored on server but not displayed in the HTML DOM

Posted on 2014-02-08
2
402 Views
Last Modified: 2014-02-08
Hello,

I have a code here where I display an image and when I click on it,
it becomes a canvas.
It is OK but I want in my website to display only the CANVAS .
Is there a way to load the canvas without displaying the image it comes from on the screen?

Thanks for any help.


<!DOCTYPE html>
<html>
  <head>

    <title>ANIMATION with timer: a solution very difficult to apply</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> 
 </head>
  <body>
  
  <img id = "img_src13" src="http://www.thecacaocafe.com/img/test.png"  width="448">
  
  <br>
  
  AAAA
 <canvas id="myCanvas_IN" width="448" height="448"></canvas><br>
 
 
	

<script>
$(function() {
	  
	$("#img_src13").click( function()
		{
		run1=0;
		canvas_in = $("#myCanvas_IN");
		canvasinPosition = {
			x: canvas_in.offset().left,
			y: canvas_in.offset().top
		};
		num = 1;	
		img_srcin="img_src13";
		elemin = document.getElementById("myCanvas_IN");
		if (elemin && elemin.getContext) 
			{
			   contextin = elemin.getContext("2d");
			  if (contextin) 
				{

				 imgin=document.getElementById(img_srcin);
				contextin.drawImage(imgin,0,0);
				}
			}
		 imgdin = contextin.getImageData(0, 0, 448, 448);
		 pixin = imgdin.data;
		});
});

 	   
    </script>
  </body>
</html>

Open in new window

0
Comment
Question by:DavidInLove
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39843990
you may hide the image with CSS : http://jsfiddle.net/kyMsW/1/
0
 

Author Closing Comment

by:DavidInLove
ID: 39844529
Yes, thank you!
And with your code JQUERY the canvas is displayed without clicking.
It is exactly what I wanted.
See you, David
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now