0

I can use the javascript to get the image data from html:

function imageClicked(e) {
            //alert(this.getAttribute("src"));
            var canvas = document.createElement("canvas");
            var context = canvas.getContext("2d");
            canvas.width = this.width;
            canvas.height = this.height;
            context.drawImage(this,0,0,this.width,this.height);
            loadURL(canvas.toDataURL("image/png"));
            e.stopPropagation();  // <=== Prevents the click reaching the div
        }

But the image does not as clear as it shows in html ,it is compressed. How to get the image not being compressed? The raw image showed in UIWebView is below, we can see the words in the image is very clear: enter image description here

The Next picture is got from the javascript and then shows it,it is not very clear:

enter image description here

leizh00701
  • 1,893
  • 5
  • 21
  • 32

1 Answers1

0

This answer will help you, you need set the second argument:

canvas.toDataURL(type,quality);
Community
  • 1
  • 1
Yangguang
  • 1,785
  • 9
  • 10