Пример #1
0
        public Form1()
        {
            InitializeComponent();
            string author;
            int    grid;

            Warping.InitForm(out author, out grid);
            Text += " (rev: " + rev + ") '" + author + '\'';
            numericParam.Value = grid;
        }
Пример #2
0
        /// <summary>
        /// Inits a new original picture.
        /// </summary>
        /// <param name="newOriginal">New original picture</param>
        public void InitPicture(Form1 f, Bitmap newOriginal, int columns, int rows)
        {
            form   = f;
            Image  = (Bitmap)newOriginal.Clone();
            width  = Image.Width;
            height = Image.Height;

            warp = new Warping();
            warp.GenerateTriangleMesh(columns, rows);
            Invalidate();
        }
Пример #3
0
        /// <summary>
        /// Warps the given source image from the given source mesh to this (current) mesh.
        /// </summary>
        /// <param name="sourceImage">Source raster image.</param>
        /// <param name="sourceMesh">Source mesh in [0,1]x[0,1] coordinate space.</param>
        /// <returns>Target raster image.</returns>
        public Bitmap Warp(Bitmap sourceImage, Warping sourceMesh)
        {
            int    wid    = sourceImage.Width;
            int    hei    = sourceImage.Height;
            Bitmap target = new Bitmap(wid, hei, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            // !!!{{ TODO: put your image-transformation code here

            int  x, y;
            bool flip = (DateTime.Now.Second & 1) > 0;

            for (y = 0; y < hei; y++)
            {
                for (x = 0; x < wid; x++)
                {
                    target.SetPixel(x, y, sourceImage.GetPixel(x, flip ? hei - 1 - y : y));
                }
            }

            // !!!}}

            return(target);
        }