开发者

Bending bitmap images - just like in PS5. Algorithms? Code? image processing?

Starting with a bitmap image ..

Bending bitmap images - just like in PS5. Algorithms? Code? image processing?

Is there a 开发者_如何转开发trivial way to do this in cocoa I don't know about? (Like "CAShapeLayer for images!")?


The easy way (which is certainly worth considering if you’re targeting a phone) is to use a grid deformation: deform a grid of squares/triangles and texture map your picture onto it. This is easily hardware-accelerated with OpenGL ES. The geometry can be as finely-meshed as you want, but the limited quality of texture sampling may be an issue depending on your application.


The concept is simple, even if the implementation is not.

  1. Define a mathematical mapping from a position in the output image to a position in the input image. This is probably the hard part, since you're likely to have a formula going from input to output rather than vice versa.
  2. For each pixel of the output image, determine its coordinates in the input. These will likely have some fractional component, i.e. they won't line up exactly with the input.
  3. Use the interpolation algorithm of your choice to determine what the value should be at the input point you've chosen.
  4. Rinse and repeat.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜