title: Create a polygon filled with a clamp image in c#
body: <p>There is request to add one image on a certain position and inside of specific polygon on other image.</p>
  
  <p>I have used following code:</p>
  
  <pre><code>private static void MergeBitmaps(string ImageFore, string ImageBack)
  {
      try
      {
          Point point1 = new Point(833, 278);
          Point point2 = new Point(1876, 525);
          Point point3 = new Point(1876, 837);
          Point point4 = new Point(833, 830);
  
          Point[] curvePoints = { point1, point2, point3, point4 };
  
          Bitmap imgB = new Bitmap(ImageBack);
          Bitmap imgF = new Bitmap(ImageFore);
          Bitmap m = new Bitmap(ImageBack);
          System.Drawing.Graphics myGraphic = System.Drawing.Graphics.FromImage(m);
  
          myGraphic.SmoothingMode = SmoothingMode.HighQuality;
          myGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
          myGraphic.PixelOffsetMode = PixelOffsetMode.HighQuality;
          TextureBrush brush = new TextureBrush(imgF);
          brush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
  
          myGraphic.FillPolygon(brush, curvePoints);
          myGraphic.Save();
          m.Save(@"new location", System.Drawing.Imaging.ImageFormat.Jpeg);
      }
      catch (Exception ex)
      {
          Console.WriteLine(ex.StackTrace);
      }
  }
  </code></pre>
  
  <p>So, <code>imgF</code> should be placed inside of polygon determined by points on <code>imgB</code>. <code>imgF</code> should be stretched inside of that polygon, to fit. Reading documentation I found that this should be set up:</p>
  
  <pre><code> brush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
  </code></pre>
  
  <p>but it doesn't work. When it is turn on, <code>imgF</code> is not drawn at all. If that line is removed or set up like this:</p>
  
  <pre><code> brush.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
  </code></pre>
  
  <p>Then <code>imgF</code> is repeated several times.</p>
  
  <p>So how to make <code>imgF</code> to be starched, to fit, to re-size and place inside of polygon?</p>
  
  <p>I don't need rectangle, because it is not shape determined with same bottom and down edge or left and right edge.</p>