Go back to Efl.Gfx.Filter.
Apply a displacement map on a buffer. This has the effect of moving the input pixels based on the values of the corresponding pixels in the displacement buffer.
displace ({ map, intensity = 10, flags = 0, src = input, dst = output, fillmode = 'repeat' })
map | An RGBA buffer containing a displacement map. See below for more details. |
intensity | Maximum distance for the displacement. The value 255 in the displacement map will then represent a displacement of intensity pixels. |
flags | This defines how pixels should be treated when going out of the source image bounds. Must be one of “default” , “nearest” , “smooth” , “nearest_stretch” or “smooth_stretch” . “default” is equivalent to “smooth_stretch” . |
src | Source buffer. |
dst | Destination buffer. Must be of same color format and size as src. |
fillmode | Defines how to handle cases where the map has a different size from src and dst. It should be a combination of stretch or repeat: none is not supported. See Fill modes. |
The map buffer is an RGBA image containing displacement and alpha values. Its size can be different from src or dst.
Considering I(x, y) represents the pixel at position (x, y) in the image I, then here is how the displacement is applied to dst:
D = map (x, y) dst (x, y) = D.alpha / 255 * src (x + (D.red - 128) * intensity / 128, y + (D.green - 128) * intensity / 128) + (255 - D.alpha) / 255 * dst (x, y)
Of course, the real algorithm takes into account interpolation between pixels as well.