/**
        For each pixel location in the new buffer P' (NewX, NewY), do:
            Find corresponding old location, P = W-1.P'
            Validate that this old location lie inside the original image boundary (i.e. 0 ≤ OldX < W,  0  ≤ Old Y < H). Otherwise, set the new empty pixel to 0 and continue to next location.
            If Validated, apply Bilinear Interpolation Algorithm to get the new pixel value, as follows:(Refer to above figure)
                */
        public BufferedImage apply_transformation_matrix_to_bitmap_or_buffer(Matrix _transformations_matrix, BufferedImage _src_img, int _new_width, int _new_height, TextBox _console)
        {
            BufferedImage ret = new BufferedImage(_new_width, _new_height);
            BilinearInterpolation obj_bi_lin_interpol = new BilinearInterpolation();
            for (int i = 0; i < _new_width; i++)
            {
                for (int j = 0; j < _new_height; j++)
                {
                    PointF[] points = {
                                          new PointF(i, j)
                                      };
                    _transformations_matrix.TransformPoints(points);
                    _console.Text += "P = (" + points[0].X + ", " + points[0].Y + ")";
                    _console.Text += Environment.NewLine;
                    _console.Text += "P' = (" + i + ", " + j + ")";
                    _console.Text += Environment.NewLine;

                    Color _color = Color.FromArgb(0);
                    if(points[0].X >= 0 && points[0].X < _src_img.width && points[0].Y >= 0 && points[0].Y < _src_img.height)
                        _color = obj_bi_lin_interpol.calculate(_src_img, points[0].X, points[0].Y);
                    ret.buffer[i, j] = _color;
                }
            }
            return ret;
        }
        /**
        For each pixel location in the new buffer P' (NewX, NewY), do:
            Find corresponding old location, P = W-1.P'
            Validate that this old location lie inside the original image boundary (i.e. 0 ≤ OldX < W,  0  ≤ Old Y < H). Otherwise, set the new empty pixel to 0 and continue to next location.
            If Validated, apply Bilinear Interpolation Algorithm to get the new pixel value, as follows:(Refer to above figure)
                */
        public bufferedLockBitmap apply_transformation_matrix_to_bitmap_or_buffer(Matrix _transformations_matrix, bufferedLockBitmap _src_img, int _new_width, int _new_height)
        {
            Bitmap temp = new Bitmap(_new_width, _new_height);
            bufferedLockBitmap ret = new bufferedLockBitmap(temp);
            ret.LockBits();
            BilinearInterpolation obj_bi_lin_interpol = new BilinearInterpolation();
            for (int i = 0; i < _new_width; i++)
            {
                for (int j = 0; j < _new_height; j++)
                {
                    PointF[] points = {
                                          new PointF(i, j)
                                      };
                    _transformations_matrix.TransformPoints(points);

                    Color _color = Color.FromArgb(0);
                    if (points[0].X >= 0 && points[0].X < _src_img.source.Width && points[0].Y >= 0 && points[0].Y < _src_img.source.Height)
                        _color = obj_bi_lin_interpol.calculate(_src_img, points[0].X, points[0].Y, _new_width, _new_height);
                    ret.SetPixel(i, j, _color);
                }
            }
            ret.UnlockBits();
            return ret;
        }