# C1.Util.DX.WIC.BitmapFrameEncode.WriteSource

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Util_DX_WIC_BitmapFrameEncode_WriteSource_" data-uid="C1.Util.DX.WIC.BitmapFrameEncode.WriteSource*">WriteSource Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Util_DX_WIC_BitmapFrameEncode_WriteSource_" data-uid="C1.Util.DX.WIC.BitmapFrameEncode.WriteSource*"></a>
<h4 id="C1_Util_DX_WIC_BitmapFrameEncode_WriteSource_C1_Util_DX_WIC_BitmapSource_" data-uid="C1.Util.DX.WIC.BitmapFrameEncode.WriteSource(C1.Util.DX.WIC.BitmapSource)">WriteSource(BitmapSource)</h4>
<div class="markdown level1 summary"><p>Encodes a bitmap source.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void WriteSource(BitmapSource bitmapSource)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub WriteSource(bitmapSource As BitmapSource)</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="C1.Util.DX.WIC.BitmapSource.html">BitmapSource</a></td>
      <td><span class="parametername">bitmapSource</span></td>
      <td><dd>
    <p>The bitmap source to encode.</p>
</dd>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_WIC_BitmapFrameEncode_WriteSource_C1_Util_DX_WIC_BitmapSource__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>If <strong>SetSize</strong> is not called prior to calling <strong>WriteSource</strong>, the size given in <em>prc</em> is used if not <strong><code>null</code></strong>. Otherwise, the size of the <strong><a class="xref" href="C1.Util.DX.WIC.BitmapSource.html">BitmapSource</a></strong> given in <em>pIBitmapSource</em> is used. </p>
<p>If <strong>SetPixelFormat</strong> is not called prior to calling <strong>WriteSource</strong>, the pixel format of the <strong><a class="xref" href="C1.Util.DX.WIC.BitmapSource.html">BitmapSource</a></strong> given in <em>pIBitmapSource</em> is used.</p>
<p>If <strong>SetResolution</strong> is not called prior to calling <strong>WriteSource</strong>, the pixel format of <em>pIBitmapSource</em> is used.</p>
<p>If <strong>SetPalette</strong> is not called prior to calling <strong>WriteSource</strong>, the target pixel format is indexed, and the pixel format of <em>pIBitmapSource</em> matches the encoder frame's pixel format, then the <em>pIBitmapSource</em> pixel format is used.</p>
<p>When encoding a GIF image, if the global palette is set and the frame level palette is not set directly by the user or by a custom independent software vendor (ISV) GIF codec, <strong>WriteSource</strong> will use the global palette to encode the frame even when <em>pIBitmapSource</em> has a frame level palette.</p>
<p>
    <strong>Windows Vista:</strong>The source rect width must match the width set through SetSize. Repeated <strong>WriteSource</strong> calls can be made as long as the total accumulated source rect height is the same as set through SetSize.</p>
</div>


<a id="C1_Util_DX_WIC_BitmapFrameEncode_WriteSource_" data-uid="C1.Util.DX.WIC.BitmapFrameEncode.WriteSource*"></a>
<h4 id="C1_Util_DX_WIC_BitmapFrameEncode_WriteSource_C1_Util_DX_WIC_BitmapSource_C1_Util_DX_RectL_" data-uid="C1.Util.DX.WIC.BitmapFrameEncode.WriteSource(C1.Util.DX.WIC.BitmapSource,C1.Util.DX.RectL)">WriteSource(BitmapSource, RectL)</h4>
<div class="markdown level1 summary"><p>Encodes a bitmap source.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void WriteSource(BitmapSource bitmapSourceRef, RectL rectangleRef)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub WriteSource(bitmapSourceRef As BitmapSource, rectangleRef As RectL)</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="C1.Util.DX.WIC.BitmapSource.html">BitmapSource</a></td>
      <td><span class="parametername">bitmapSourceRef</span></td>
      <td><dd>
    <p>The bitmap source to encode.</p>
</dd>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Util.DX.RectL.html">RectL</a></td>
      <td><span class="parametername">rectangleRef</span></td>
      <td><dd>
    <p>The size rectangle of the bitmap source.</p>
</dd>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_WIC_BitmapFrameEncode_WriteSource_C1_Util_DX_WIC_BitmapSource_C1_Util_DX_RectL__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>If <strong>SetSize</strong> is not called prior to calling <strong>WriteSource</strong>, the size given in <em>prc</em> is used if not <strong><code>null</code></strong>. Otherwise, the size of the <strong><a class="xref" href="C1.Util.DX.WIC.BitmapSource.html">BitmapSource</a></strong> given in <em>pIBitmapSource</em> is used. </p>
<p>If <strong>SetPixelFormat</strong> is not called prior to calling <strong>WriteSource</strong>, the pixel format of the <strong><a class="xref" href="C1.Util.DX.WIC.BitmapSource.html">BitmapSource</a></strong> given in <em>pIBitmapSource</em> is used.</p>
<p>If <strong>SetResolution</strong> is not called prior to calling <strong>WriteSource</strong>, the pixel format of <em>pIBitmapSource</em> is used.</p>
<p>If <strong>SetPalette</strong> is not called prior to calling <strong>WriteSource</strong>, the target pixel format is indexed, and the pixel format of <em>pIBitmapSource</em> matches the encoder frame's pixel format, then the <em>pIBitmapSource</em> pixel format is used.</p>
<p>When encoding a GIF image, if the global palette is set and the frame level palette is not set directly by the user or by a custom independent software vendor (ISV) GIF codec, <strong>WriteSource</strong> will use the global palette to encode the frame even when <em>pIBitmapSource</em> has a frame level palette.</p>
<p>
    <strong>Windows Vista:</strong>The source rect width must match the width set through SetSize. Repeated <strong>WriteSource</strong> calls can be made as long as the total accumulated source rect height is the same as set through SetSize.</p>
</div>


<a id="C1_Util_DX_WIC_BitmapFrameEncode_WriteSource_" data-uid="C1.Util.DX.WIC.BitmapFrameEncode.WriteSource*"></a>
<h4 id="C1_Util_DX_WIC_BitmapFrameEncode_WriteSource_C1_Util_DX_WIC_BitmapSource_System_IntPtr_" data-uid="C1.Util.DX.WIC.BitmapFrameEncode.WriteSource(C1.Util.DX.WIC.BitmapSource,System.IntPtr)">WriteSource(BitmapSource, IntPtr)</h4>
<div class="markdown level1 summary"><p>HRESULT IWICBitmapFrameEncode::WriteSource([In, Optional] IWICBitmapSource* pIBitmapSource,[In] void* prc)</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void WriteSource(BitmapSource bitmapSourceRef, IntPtr rectangleRef)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub WriteSource(bitmapSourceRef As BitmapSource, rectangleRef As IntPtr)</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="C1.Util.DX.WIC.BitmapSource.html">BitmapSource</a></td>
      <td><span class="parametername">bitmapSourceRef</span></td>
      <td></td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.intptr">IntPtr</a></td>
      <td><span class="parametername">rectangleRef</span></td>
      <td></td>
    </tr>
  </tbody>
</table>
</div>
