Bending bitmaps - just like in the PS5. Algorithms? Code? Image processing?

Starting with a bitmap.

alt text

Is there a trivial way to do this in cocoa that I don't know about? (Like "CAShapeLayer for Images!")?

+4
source share
2 answers

An easy way (which, of course, is worth considering if you are aiming the phone) is to use grid deformation: deform the grid of squares / triangles and textures, draw your picture on it. It is easily hardware accelerated with OpenGL ES. Geometry may be as fine as you want, but limited texture fetch quality can be a problem depending on your application.

+2
source

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

  • Define a mathematical mapping from a position on the output image to a position on the input image. This is probably the tricky part, as you are likely to have a formula going from input to output, and not vice versa.
  • For each pixel of the output image, determine its coordinates at the input. They will probably have some fractional component, i.e. They will not exactly match the input.
  • Use the interpolation algorithm of your choice to determine what value should be at your chosen entry point.
  • Rinse and repeat.
+2
source

Source: https://habr.com/ru/post/1333610/


All Articles