for (int y = 0; y < img.Height; ++y)
{
Span<Rgba32> pixelRowSpan = img.GetPixelRowSpan(y);
for (int x = 0; x < img.Width; ++x)
{
int y1 = Convert.ToInt32(y + 20.0 * Math.Sin(x / 32.0));
if (y1 >= img.Height)
y1 = img.Height - 1;
if (y1 < 0)
y1 = 0;
var sourcePixel = img.GetPixelRowSpan(y1)[x];
pixelRowSpan[x] = sourcePixel;
}
}