title: How To Crop Captured Image? --C#
body: <p>Is it possible to crop the captured image based on the shape that I want? I'm using raw image + web cam texture to activate the camera and save the image. And I'm using UI Image overlay method as a mask to cover the unwanted parts. I will be attaching the picture to the char model in the latter part. Sorry, I am new to unity. Grateful for your help! </p>
  
  <p><a href="https://i.stack.imgur.com/wKze4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wKze4.jpg" alt="enter image description here"></a></p>
  
  <p>Below is what I have in my code:</p>
  
  <pre><code>// start cam
   void Start () {
       devices = WebCamTexture.devices;
       background = GetComponent&lt;RawImage&gt; ();
       devCam = new WebCamTexture ();
       background.texture = devCam;
       devCam.deviceName = devices [0].name;
       devCam.Play ();
   }
  
   void OnGUI()
   {
       GUI.skin = skin;   
          //swap front and back camera
       if (GUI.Button (new Rect ((Screen.width / 2) - 1200, Screen.height - 650, 250, 250),"", GUI.skin.GetStyle("btn1"))) {
           devCam.Stop();
           devCam.deviceName = (devCam.deviceName == devices[0].name) ? devices[1].name : devices[0].name;
           devCam.Play();
       }
           //snap picture
       if (GUI.Button (new Rect ((Screen.width / 2) - 1200, Screen.height - 350, 250, 250), "", GUI.skin.GetStyle ("btn2"))) {
           OnSelectCapture ();
                  //freeze cam here?
       }
   }
  
  
   public void OnSelectCapture()
   {
       imgID++;
       string fileName = imgID.ToString () + ".png";
       Texture2D snap = new Texture2D (devCam.width, devCam.height); 
       Color[] c;                                                         
       c = devCam.GetPixels ();                             
       snap.SetPixels (c);                                                 
       snap.Apply ();                                                    
  
       // Save created Texture2D (snap) into disk as .png
       System.IO.File.WriteAllBytes (Application.persistentDataPath +"/"+ fileName, snap.EncodeToPNG ());
   }
  </code></pre>
  
  <p>}</p>