private void btnxyaffineStart_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                var img = new Img(ofd.FileName);

                var w = img.Width;
                var h = img.Height;


                // -- Set Ratio
                RatioW = w / cvsOriginal.Width;
                RatioH = h / cvsOriginal.Height;


                // --


                var data = img.Data.TointArray();

                // ------------
                imgOriginal.Source = new BitmapImage(new Uri(ofd.FileName));



                // ------------

                var p1 = new Point(132, 103);
                var p2 = new Point(100, 101);

                var srcPos = new AffinePos(
                    178, 1902,
                    132, 103,
                    933, 57,
                    0, 0
                    );

                var trgPos = new AffinePos(
                    100, 1900,
                    100, 101,
                    1901, 101,
                    0, 0
                    );



                int[,] ResultArray = xytransform(data, srcPos, trgPos);

                /// Start To Bitmap
                //var bmpsource = ResultArray.ToBitmap().ToImageSource();
                var bmpsource = ResultArray.ToBitmap_SetPixel().ToImageSource();

                imgRotated.Source = bmpsource;


                // SAve
                string path = @"C:\Data\Rotated.jpg";
                ExtLib.SaveImg(path, bmpsource);
            }
        }
        private void btnWithPointStart_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                var img = new Img(ofd.FileName);

                var w = img.Width;
                var h = img.Height;


                // -- Set Ratio
                RatioW = w / cvsOriginal.ActualWidth;
                RatioH = h / cvsOriginal.ActualHeight;
                // --

                var data = img.Data.TointArray();

                // ------------
                imgOriginal.Source = new BitmapImage(new Uri(ofd.FileName));
                // ------------


                if (LBPos == null || LTPos == null || RTPos == null)
                {
                    return;
                }

                var srcPos = new AffinePos(LBPos, LTPos, RTPos, RBPos);

                var trgPos = srcPos.GetCentered(new Point(w / 2, h / 2));


                var poslist = new PointD[4] {
                    LBPos, LTPos, RTPos, RBPos
                };

                var afindata = new AffinePos(LBPos, LTPos, RTPos, RBPos);

                var recipe = afindata.ToTrnsData(w, h);


                int[,] ResultArray = rotateGeneral(data, recipe.W, recipe.H, recipe.Angle, true);

                if (ResultArray == null)
                {
                    return;
                }
                /// Start To Bitmap
                //var bmpsource = ResultArray.ToBitmap().ToImageSource();
                var bmpsource = ResultArray.ToBitmap_SetPixel().ToImageSource();

                imgRotated.Source = bmpsource;


                // SAve
                string path = @"C:\Data\Rotated.jpg";
                ExtLib.SaveImg(path, bmpsource);
            }
        }