'How to keep the original picture when I zoom a picture in a picturebox?

The purpose: In a picturebox I want to use wheel to zoom in or zoom out the picture. The method I get the image is to read the picturebox's image(like picture 1) I use the Cubic interpolation method to zoom the picture. As I zoom in and out many times, the picture would be very blurry(Because many times Cubic interpolation). So how can I solve the problem?

 void pictureBox1_MouseWheel(object sender, MouseEventArgs e)
    {

        //Console.WriteLine("hhh");
        int i = e.Delta * SystemInformation.MouseWheelScrollLines ;
        System.Drawing.Point p = e.Location;
        // get picturebox image
        Mat OriginPictureMat = new Mat();
        Bitmap bit_image = new Bitmap(pictureBox1.Image);
        OriginPictureMat = ConvertFile.BitmapToMat(bit_image);
        /// 

        /// Zoom the picture
        Mat ZoomPictureMat = new Mat();
        OpenCvSharp.Size ZoomDsize = new OpenCvSharp.Size();
        int diff_origincenter_pointX = p.X  ; 
        int diff_origincenter_pointY = p.Y ;
        // zoom scale
        float scale_float = 1 + i / 3600f;
        int ZoomWidth = (int)Convert.ToInt32(OriginPictureMat.Width * scale_float);
        int ZoomHeight = (int)Convert.ToInt32(OriginPictureMat.Height * scale_float);
        if(ZoomHeight<OriginPictureMat.Height || ZoomWidth < OriginPictureMat.Width)
        {
            ZoomDsize = new OpenCvSharp.Size(OriginPictureMat.Width, OriginPictureMat.Height);
        }
        else
        {
            ZoomDsize =  new OpenCvSharp.Size(ZoomWidth, ZoomHeight);
        }

        Cv2.Resize(OriginPictureMat, ZoomPictureMat, ZoomDsize, 0, 0, InterpolationFlags.Cubic);

        //get the center point 

        Rect rect = new Rect((int)(scale_float * p.X) - diff_origincenter_pointX, (int)(scale_float * p.Y) - diff_origincenter_pointY, OriginPictureMat.Width, OriginPictureMat.Height);
        Mat matfinal = new Mat(ZoomPictureMat,rect);
        Bitmap bitmapFinal = ConvertFile.MatToBitmap(matfinal);
        pictureBox1.Image = bitmapFinal;
        matfinal = null;
        OriginPictureMat = null;
        ZoomPictureMat = null;
        GC.Collect();





    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source