1. <html>
  2. <head>
  3.  
  4. <script type="application/x-javascript">
  5.  
  6. function copyToClipboard(m_text)
  7. {
  8. netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
  9. var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
  10.  
  11. if (!clip) return false;
  12. var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
  13. if (!trans) return false;
  14. trans.addDataFlavor('text/unicode');
  15.  
  16. var str = new Object();
  17. var len = new Object();
  18. var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
  19. str.data=m_text;
  20. trans.setTransferData("text/unicode",str,m_text.length*2);
  21. var clipid=Components.interfaces.nsIClipboard;
  22. if (!clipid) return false;
  23. clip.setData(trans,null,clipid.kGlobalClipboard);
  24.  
  25. return false;
  26. }
  27.  
  28. function draw()
  29. {
  30. <?
  31. $image_path = "png2.png";
  32. if ( isset($_GET['s']) ) $image_path = "png.png";
  33. $im_h = imagecreatefrompng($image_path);
  34. list($image_x, $image_y) = getimagesize($image_path);
  35.  
  36. for ( $i = 1; $i <= $image_x; $i++ )
  37. {
  38. echo 'var canvas = document.getElementById("canvas_'.$i.'");';
  39. echo 'if (canvas.getContext){var ctx = canvas.getContext("2d");';
  40.  
  41. for ( $j = 0; $j <= $image_y; $j++ )
  42. {
  43. $rgb = imagecolorat($im_h, $i, $j);
  44. $r_rgb = ($rgb >> 16) & 0xff;
  45. $g_rgb = ($rgb >> 8) & 0xff;
  46. $b_rgb = $rgb & 0xff;
  47. echo 'ctx.fillStyle = "rgba("+'.$r_rgb.'+","+'.$g_rgb.'+","+'.$b_rgb.'+","+1+")";ctx.fillRect('.(0).', '.$j.', 1, 1);';
  48. }
  49. echo '}'; }
  50. ?>
  51.  
  52. }
  53.  
  54. </script>
  55. </head>
  56.  
  57. <body onLoad = "copyToClipboard(''); draw();">;
  58. <div id = "x" style = "width:100%; height:100%; position:absolute; top:0px; left:0px; background-color:white; z-index:0" onmouseover = "this.style.zIndex='0'; copyToClipboard('')"></div>
  59. <div id = "y" style = "width:100%; height:100%; position:absolute; top:0px; left:0px; z-index:0" onmouseout = "x.style.zIndex='1'; copyToClipboard('')">;
  60.  
  61. <? for ( $i = 1; $i <= $image_x; $i++ ) echo '<canvas id="canvas_'.$i.'" width="'.(1).'" height="'.$image_y.'"></canvas>'; ?>
  62. </div>;
  63.  
  64.  
  65. </body>
  66. </html>
  67.  
  68.