よいお年をお迎えください。
@home
[DFA Macro 100mmF2.8]
public static bool NLInsideOut(ref Bitmap bmp, double cx, double cy, double radius, double index, Color bkColor) { if (bmp.PixelFormat != PixelFormat.Format24bppRgb) return false; int w = bmp.Width; int h = bmp.Height; int mg = 2; // margin for interpolations if ((cx == 0) & (cy == 0)) { cx = (double)w / 2; cy = (double)h / 2; } Bitmap tmp = new Bitmap(w + mg * 2, h + mg * 2, bmp.PixelFormat); Graphics g = Graphics.FromImage(tmp); g.Clear(bkColor); g.DrawImageUnscaled(bmp, mg, mg); g.Dispose(); g = Graphics.FromImage(bmp); if (bkColor != Color.Transparent) g.Clear(bkColor); g.Dispose(); RectangleF rct = new RectangleF(-1, -1, w + 1, h + 1); double r, a, xx, yy; double rindex = 1d / index; BmpProc24 src = new BmpProc24(tmp); BmpProc24 dst = new BmpProc24(bmp); for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) { r = Math.Sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)); if (r > radius) continue; r = radius * Math.Pow((1d - r / radius), rindex); a = Math.Atan2(y - cy, x - cx); // radian xx = r * Math.Cos(a) + cx; yy = r * Math.Sin(a) + cy; if (rct.Contains(new PointF((float)xx, (float)yy))) { xx = xx + mg; yy = yy + mg; ImgUtils.intBicubic(dst, src, x, y, xx, yy); } } ImgUtils.CallDispose(dst, src, tmp); return true; }