Regional Medical mobile medical imaging solution-HTML5-based PACS--HTML5 Image Processing

Source: Internet
Author: User

Main html page code: <canvas id = "imageCanvas"> </canvas> javascript main code: Copy code 1 2 var canvas =$ ("# imageCanvas "). get (0); 3 var context = canvas. getContext ("2d"); 4 var oldX, oldY, newX, newY; 5 var enabled = false; 6 canvas. onmousedown = function (event) {7 enabled = true; 8 oldX = event. clientX; // in actual use, you need to obtain the relative position of the mouse in the element. In this way, you can directly obtain the clientX 9 oldY = event of the event. clientY; // obtain the relative position of the mouse in the element in actual use. In this way, the clientY10 11} of the event is obtained directly. 12 Canvas. onmouseup = function (event) {13 enabled = false; 14}; 15 canvas. onmousemove = function (event) {16 if (! Enabled) {17 return; 18} 19 newX = event. clientX; // in actual use, you need to obtain the relative position of the mouse in the element. In this way, you can directly obtain the clientX20 newY = event of the event. clientY; // in actual use, you need to obtain the relative position of the mouse in the element. In this way, you can directly obtain the clientY21 moveImage (); 22 oldX = newX; 23 oldY = newY; 24}; 25 function moveImage () {26 var moveX = (newX-oldX); 27 var moveY = (newY-oldY); 28 29 30 // 31 context for image movement. transform (, moveX, moveY); 32 context. drawImage (image); 33 34}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.