简体   繁体   中英

Resizing Canvas by adding space on top and left..?

Is it possible to resize canvas by adding a fresh space on top and left of the canvas - by adding dx pixels on left and dy pixels on top? If so, what is the best optimized solution to do that, if the current canvas is very large...?

Yes this is possible with an in-memory canvas. All you have to do is "save" the canvas bitmap by drawing it to a temporary in-memory canvas, resize your canvas, and draw back the old bitmap in the right place.

Here's a live example of that:

http://jsfiddle.net/simonsarris/YdtEd/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM