How does js achieve the screenshot function like Wechat on pc?

does anyone know how the front end implements this screenshot function similar to Wechat"s PC end? have they studied the html2canvas plug-in, which seems to only capture the full screen and cannot stretch the selected area

like Wechat?
Jun.22,2021

js runs in the browser, so js can do what the browser tells you to do, and js can't do what the browser doesn't let you do.

so it is not possible to take a screenshot directly. Html2canvas actually draws it again with canvas.

depending on your specific needs, there are many options to consider, such as browser extension.


if you are intercepting an area inside the browser, although there is no similar requirement, if you want me to do so, I will probably do so. First, use html2canvas to capture the full screen of the browser and return the corresponding canvas instance. Then you should be able to obtain a local image using getImageData (sx, sy, sw, sh). The key is to know the values of the four parameters sx, sy, sw, sh. This is easier to implement, just make a fake intercept control.

it is not possible to capture any area of the screen.

Menu