Canvas redraws the picture is very blurry, is there any way to improve the quality of the picture?

the picture synthesizes the text, and when the but picture is generated, the QR code cannot be scanned. Does anyone know how to solve this problem?
clipboard.png

Mar.20,2021

I don't know whether to use off-screen Canvas,. Note that Canvas uses native width and height attributes to set width and height as far as possible. Do not use CSS, and do not use it together. In addition, such as the QR code is actually a need for sharp edges and vector-style images, output as far as possible to use PNG, rather than lossy compression of JPEG, especially when your picture is very small, it will be easier to paste.

in addition, if there is a lot of content in the QR code, you can appropriately reduce the bit error rate (the default is 40%, which can be adjusted to a lower level), so as to make the square in the QR code larger and clearer, and also partially counteract the impact of blurred images.


how do you write the width and height of canvas?

    canvas.width = '300px'
    canvas.height = '300px'

canvas setting height does not need to use attr, directly modify width or height, you try


I've come up with a solution. Because it is to generate pictures.
$('- sharpmain'). Attr ("width", $("- sharpstarImg"). Width () * 2.5);
$('- sharpmain'). Attr ("height", $("- sharpstarImg"). Height () * 2.5);

is directly set to enlarge the canvas. Hide.
then set the adaptive width and height for the picture. The quality of the picture is basically the same as the original


canvas rendering blur may be due to the need to adapt to retina.

you can refer to this: https://github.com/PengJiyuan.

and before drawing, try adding ctx.translate (0.5,-0.5).

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c75b-2c310.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c75b-2c310.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?