# C1.Xaml.Pdf.C1PdfDocument.DrawImage

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Xaml_Pdf_C1PdfDocument_DrawImage_" data-uid="C1.Xaml.Pdf.C1PdfDocument.DrawImage*">DrawImage Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Xaml_Pdf_C1PdfDocument_DrawImage_" data-uid="C1.Xaml.Pdf.C1PdfDocument.DrawImage*"></a>
<h4 id="C1_Xaml_Pdf_C1PdfDocument_DrawImage_System_Windows_Media_Imaging_WriteableBitmap_System_Windows_Rect_C1_Util_ContentAlignment_System_Windows_Media_Stretch_" data-uid="C1.Xaml.Pdf.C1PdfDocument.DrawImage(System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect,C1.Util.ContentAlignment,System.Windows.Media.Stretch)">DrawImage(WriteableBitmap, Rect, ContentAlignment, Stretch)</h4>
<div class="markdown level1 summary"><p>Draws the specified <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a> object at the specified location,
adjusting the image size as specified by the <code class="paramref">align</code> and
<code class="paramref">stretch</code> parameters.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void DrawImage(WriteableBitmap img, Rect rc, ContentAlignment align, Stretch stretch)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub DrawImage(img As WriteableBitmap, rc As Rect, align As ContentAlignment, stretch As Stretch)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a></td>
      <td><span class="parametername">img</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a> object to draw.</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">Rect</span></td>
      <td><span class="parametername">rc</span></td>
      <td><p><span class="xref">System.Windows.Rect</span> structure that specifies the location of the drawn image, in points from the top left corner of the page.</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">ContentAlignment</span></td>
      <td><span class="parametername">align</span></td>
      <td><p><span class="xref">C1.Util.ContentAlignment</span> value that specifies how the image should be aligned within the rectangle.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.stretch">Stretch</a></td>
      <td><span class="parametername">stretch</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.stretch">Stretch</a> value that specifies how the image should be sized to fit the rectangle.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Xaml_Pdf_C1PdfDocument_DrawImage_System_Windows_Media_Imaging_WriteableBitmap_System_Windows_Rect_C1_Util_ContentAlignment_System_Windows_Media_Stretch__examples">Examples</h5>
<p>The code below shows how you can use the <b>DrawImage</b> method can be used to render any
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.uielement">UIElement</a>. The code creates a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a> from the element,
then calls the <b>DrawImage</b> method:</p>
<pre><code class="lang-csharp">void DrawImage(UIElement e, Rect rc, ContentAlignment align, ImageSizeMode mode)
{
  DrawImage(new WriteableBitmap(e, null), rc, align, mode);
}</code></pre>



<a id="C1_Xaml_Pdf_C1PdfDocument_DrawImage_" data-uid="C1.Xaml.Pdf.C1PdfDocument.DrawImage*"></a>
<h4 id="C1_Xaml_Pdf_C1PdfDocument_DrawImage_System_Windows_Media_Imaging_WriteableBitmap_System_Windows_Rect_" data-uid="C1.Xaml.Pdf.C1PdfDocument.DrawImage(System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect)">DrawImage(WriteableBitmap, Rect)</h4>
<div class="markdown level1 summary"><p>Draws the specified <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a> object at the specified location,
stretching it to fit the destination rectangle.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void DrawImage(WriteableBitmap img, Rect rc)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub DrawImage(img As WriteableBitmap, rc As Rect)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a></td>
      <td><span class="parametername">img</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a> object to draw.</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">Rect</span></td>
      <td><span class="parametername">rc</span></td>
      <td><p><span class="xref">System.Windows.Rect</span> structure that specifies the location of the drawn image, in points from the top left corner of the page.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Xaml_Pdf_C1PdfDocument_DrawImage_System_Windows_Media_Imaging_WriteableBitmap_System_Windows_Rect__examples">Examples</h5>
<p>The code below shows how you can use the <b>DrawImage</b> method can be used to render any
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.uielement">UIElement</a>. The code creates a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a> from the element,
then calls the <b>DrawImage</b> method:</p>
<pre><code class="lang-csharp">void DrawImage(UIElement e, Rect rc)
{
  DrawImage(new WriteableBitmap(e, null), rc);
}</code></pre>



<a id="C1_Xaml_Pdf_C1PdfDocument_DrawImage_" data-uid="C1.Xaml.Pdf.C1PdfDocument.DrawImage*"></a>
<h4 id="C1_Xaml_Pdf_C1PdfDocument_DrawImage_System_Windows_Media_Imaging_WriteableBitmap_System_Windows_Rect_System_Windows_Rect_" data-uid="C1.Xaml.Pdf.C1PdfDocument.DrawImage(System.Windows.Media.Imaging.WriteableBitmap,System.Windows.Rect,System.Windows.Rect)">DrawImage(WriteableBitmap, Rect, Rect)</h4>
<div class="markdown level1 summary"><p>Draws the specified <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a> object at the specified location,
clipping the output to the given clipping rectangle.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void DrawImage(WriteableBitmap img, Rect rc, Rect rcClip)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub DrawImage(img As WriteableBitmap, rc As Rect, rcClip As Rect)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a></td>
      <td><span class="parametername">img</span></td>
      <td><p><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a> object to draw.</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">Rect</span></td>
      <td><span class="parametername">rc</span></td>
      <td><p><span class="xref">System.Windows.Rect</span> structure that specifies the location of the drawn image, in points from the top left corner of the page.</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">Rect</span></td>
      <td><span class="parametername">rcClip</span></td>
      <td><p><span class="xref">System.Windows.Rect</span> structure that specifies a clipping rectangle on the page. No part of the image is drawn outside the clipping rectangle.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Xaml_Pdf_C1PdfDocument_DrawImage_System_Windows_Media_Imaging_WriteableBitmap_System_Windows_Rect_System_Windows_Rect__examples">Examples</h5>
<p>The code below shows how you can use the <b>DrawImage</b> method can be used to render any
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.uielement">UIElement</a>. The code creates a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.windows.media.imaging.writeablebitmap">WriteableBitmap</a> from the element,
then calls the <b>DrawImage</b> method:</p>
<pre><code class="lang-csharp">void DrawImage(UIElement e, Rect rc, Rect rcClip)
{
  DrawImage(new WriteableBitmap(e, null), rc, rcClip);
}</code></pre>



<a id="C1_Xaml_Pdf_C1PdfDocument_DrawImage_" data-uid="C1.Xaml.Pdf.C1PdfDocument.DrawImage*"></a>
<h4 id="C1_Xaml_Pdf_C1PdfDocument_DrawImage_System_Int32_System_Int32_System_Int32___System_Windows_Rect_System_Windows_Rect_" data-uid="C1.Xaml.Pdf.C1PdfDocument.DrawImage(System.Int32,System.Int32,System.Int32[],System.Windows.Rect,System.Windows.Rect)">DrawImage(int, int, int[], Rect, Rect)</h4>
<div class="markdown level1 summary"><p>Draws the specified ARGB pixels at the specified location, clipping the output to the given clipping rectangle.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void DrawImage(int width, int height, int[] pixels, Rect rc, Rect rcClip)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub DrawImage(width As Integer, height As Integer, pixels As Integer(), rc As Rect, rcClip As Rect)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">width</span></td>
      <td><p>The width of thne image in pixels.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">height</span></td>
      <td><p>The height of thne image in pixels.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a>[]</td>
      <td><span class="parametername">pixels</span></td>
      <td><p>The ARGB color array.</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">Rect</span></td>
      <td><span class="parametername">rc</span></td>
      <td><p><span class="xref">System.Windows.Rect</span> structure that specifies the location of the drawn image, in points from the top left corner of the page.</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">Rect</span></td>
      <td><span class="parametername">rcClip</span></td>
      <td><p><span class="xref">System.Windows.Rect</span> structure that specifies a clipping rectangle on the page. No part of the image is drawn outside the clipping rectangle.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
