Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Poor quality of png images drawn into html canvas

Tags:

People also ask

Can HTML take PNG?

You can use PNG, JPEG or GIF image file based on your comfort but make sure you specify correct image file name in src attribute. Image name is always case sensitive.

Why is my PNG image not showing up in HTML?

Right click on the image and select properties. Then if you find an option "unblock" then click on it (sometimes computer blocks some images, hence on the google chrome or internet explorer it won't display) Check the following details are correct a)syntax of html b)path name c)file name d)extension of image.

How do you blur a picture on canvas?

Simply select the photo, then click “filter” and “advanced options.” Slide to the right to blur, and to the left to sharpen.


I am trying to draw png image into the canvas, but the quality is really poor. I am doing that using the drawImage method:

src = folder+self.cur+".png";
imageObj.src = src;
imageObj.onload = function() {
    context.clearRect(0, 0, cv, ch), context.drawImage(imageObj, 0, 0, cv, ch)
};

Attached is an original image and the screenshot of the result in the canvas. For now canvas dimensions are the same as the image, so the problem is not caused by the resizing.

Any ideas what is causing this issue and how to solve it? Here is a jfiddle with an example.

enter image description here