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
408 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.NET Content Page 3 35
javascript - insert into js doc help 2 25
Copying table data to one another 15 31
Clear input text 15 9
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

820 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