I'm trying to create a site that curves an image uploaded by a user, and then allows the user to save the new image. I'm having trouble figuring out how to curve the image as shown in the link below. I can create the curved shape as a solid color in Canvas, but not with an image.
相关问题
- Does using percentages instead of pixels change an
- Method for drawing circles in a pyramid pattern
- HTML5 - Canvas - Optimization for large images
- A function to preload images - need to draw them n
- Canvas fillStyle none in HTML5
相关文章
- canvas.toDataURL() not working properly [duplicate
- How to destroy / reload the canvas in html 5?
- Some Android devices extremely slow when rendering
- HTML5 Canvas: How to border a fillRect?
- Html over the Canvas?
- EaselJS Alpha Mask Filter
- Unable to Generate png Image from Html 5 Canvas
- How to count Color on Image using HTML canvas getI
There's no simple way to do this. You might need to code the transformation yourself using the pixelwise API of Canvas. See http://beej.us/blog/2010/02/html5s-canvas-part-ii-pixel-manipulation/ .
Instead of pure pixel based solution you could try a mesh based one. Split up the source image to smaller chunks that map to the target shape. Then use texture mapping to fill in the details. See Image manipulation and texture mapping using HTML5 Canvas? for the mapping algo. You may find another algo here. You'll still need to figure out the mapping coordinates, though.
I tried something like this.
I have a source image having width 300 and height 227. And I am going to bend this image 15 pixel down. So create a canvas with same width and height = imageWidth + 15 px. ie. 227+15 = 242.
HTML:
Javascript