Grid Distortion

I would like to develop a code that users can change the position on the vertices in a grid with a mouse or touch screen. A distorted grid is attached. Then I can apply the distorted grid shape to an image. Your suggestions are greatly appreciated.

OpenGL or Direct3D would be what I would use. You’d start with a grid (or more likely triangulated mesh) with overall dimensions (aspect ratio) matching your input image. Each grid point gets a texture coordinate assigned corresponding to the relative position in the grid. Then when you move the underlying grid points (change the geometry), that part of the image (as defined by the texture coordinate) gets distorted.

Most likely this will be a decent starting point, but I imagine you will want to refine it in a number of ways to make it actually useful. For example, when moving a single grid point, do other grid points in the vicinity also move with it? If so, what function defines how they move? If not, what happens when you move a grid point across an edge / boundary in your mesh? You might want to consider using a small number of points as control points that define a function of some sort (Bezier, spline, etc) which will give nice properties like smoothness etc.

But that’s just my off-the-cuff answer based on what I think you might want. Can you tell us more about what you are trying to achieve with this?