# C1.Util.DX.Direct2D.Bitmap.CopyFromMemory

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory*">CopyFromMemory Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory*"></a>
<h4 id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_System_IntPtr_System_Int32_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory(System.IntPtr,System.Int32)">CopyFromMemory(IntPtr, int)</h4>
<div class="markdown level1 summary"><p>Copies the specified region from memory into the current bitmap.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void CopyFromMemory(IntPtr pointer, int pitch)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub CopyFromMemory(pointer As IntPtr, pitch As Integer)</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.intptr">IntPtr</a></td>
      <td><span class="parametername">pointer</span></td>
      <td><p>The data to copy.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">pitch</span></td>
      <td><p>The stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory). The stride can be computed from the following formula: pixel width * bytes per pixel + memory padding.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_System_IntPtr_System_Int32__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion; the two bitmap formats should match.  Passing this method invalid input, such as an invalid destination rectangle, can produce unpredictable results, such as a distorted image or device failure. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a> and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.</p>
</div>


<a id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory*"></a>
<h4 id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_System_Byte___System_Int32_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory(System.Byte[],System.Int32)">CopyFromMemory(byte[], int)</h4>
<div class="markdown level1 summary"><p>Copies the specified region from memory into the current bitmap.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void CopyFromMemory(byte[] memory, int pitch)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub CopyFromMemory(memory As Byte(), pitch As Integer)</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.byte">byte</a>[]</td>
      <td><span class="parametername">memory</span></td>
      <td><p>The data to copy.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">pitch</span></td>
      <td><p>The stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory). The stride can be computed from the following formula: pixel width * bytes per pixel + memory padding.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_System_Byte___System_Int32__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion; the two bitmap formats should match.  Passing this method invalid input, such as an invalid destination rectangle, can produce unpredictable results, such as a distorted image or device failure. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a> and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.</p>
</div>


<a id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory*"></a>
<h4 id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory__1___0___System_Int32_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory``1(``0[],System.Int32)">CopyFromMemory&lt;T&gt;(T[], int)</h4>
<div class="markdown level1 summary"><p>Copies the specified region from memory into the current bitmap.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void CopyFromMemory&lt;T&gt;(T[] memory, int pitch = 0) where T : struct</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub CopyFromMemory(Of T As Structure)(memory As T(), Optional pitch As Integer = 0)</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>T[]</td>
      <td><span class="parametername">memory</span></td>
      <td><p>The data to copy.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">pitch</span></td>
      <td><p>The stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory). The stride can be computed from the following formula: pixel width * bytes per pixel + memory padding.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">T</span></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory__1___0___System_Int32__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion; the two bitmap formats should match.  Passing this method invalid input, such as an invalid destination rectangle, can produce unpredictable results, such as a distorted image or device failure. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a> and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.</p>
</div>


<a id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory*"></a>
<h4 id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_System_IntPtr_System_Int32_C1_Util_DX_RectL_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory(System.IntPtr,System.Int32,C1.Util.DX.RectL)">CopyFromMemory(IntPtr, int, RectL)</h4>
<div class="markdown level1 summary"><p>Copies the specified region from memory into the current bitmap.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void CopyFromMemory(IntPtr pointer, int pitch, RectL destinationArea)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub CopyFromMemory(pointer As IntPtr, pitch As Integer, destinationArea 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="https://learn.microsoft.com/dotnet/api/system.intptr">IntPtr</a></td>
      <td><span class="parametername">pointer</span></td>
      <td><p>The data to copy.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">pitch</span></td>
      <td><p>The stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory). The stride can be computed from the following formula: pixel width * bytes per pixel + memory padding.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Util.DX.RectL.html">RectL</a></td>
      <td><span class="parametername">destinationArea</span></td>
      <td><p>In the current bitmap, the upper-left corner of the area to which the region specified by srcRect is copied.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_System_IntPtr_System_Int32_C1_Util_DX_RectL__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion; the two bitmap formats should match.  Passing this method invalid input, such as an invalid destination rectangle, can produce unpredictable results, such as a distorted image or device failure. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a> and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.</p>
</div>


<a id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory*"></a>
<h4 id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_System_Byte___System_Int32_C1_Util_DX_RectL_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory(System.Byte[],System.Int32,C1.Util.DX.RectL)">CopyFromMemory(byte[], int, RectL)</h4>
<div class="markdown level1 summary"><p>Copies the specified region from memory into the current bitmap.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void CopyFromMemory(byte[] memory, int pitch, RectL destinationArea)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub CopyFromMemory(memory As Byte(), pitch As Integer, destinationArea 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="https://learn.microsoft.com/dotnet/api/system.byte">byte</a>[]</td>
      <td><span class="parametername">memory</span></td>
      <td><p>The data to copy.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">pitch</span></td>
      <td><p>The stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory). The stride can be computed from the following formula: pixel width * bytes per pixel + memory padding.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Util.DX.RectL.html">RectL</a></td>
      <td><span class="parametername">destinationArea</span></td>
      <td><p>In the current bitmap, the upper-left corner of the area to which the region specified by srcRect is copied.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_System_Byte___System_Int32_C1_Util_DX_RectL__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion; the two bitmap formats should match.  Passing this method invalid input, such as an invalid destination rectangle, can produce unpredictable results, such as a distorted image or device failure. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a> and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.</p>
</div>


<a id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory*"></a>
<h4 id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory__1___0___System_Int32_C1_Util_DX_RectL_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory``1(``0[],System.Int32,C1.Util.DX.RectL)">CopyFromMemory&lt;T&gt;(T[], int, RectL)</h4>
<div class="markdown level1 summary"><p>Copies the specified region from memory into the current bitmap.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void CopyFromMemory&lt;T&gt;(T[] memory, int pitch, RectL destinationArea) where T : struct</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub CopyFromMemory(Of T As Structure)(memory As T(), pitch As Integer, destinationArea 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>T[]</td>
      <td><span class="parametername">memory</span></td>
      <td><p>The data to copy.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">pitch</span></td>
      <td><p>The stride, or pitch, of the source bitmap stored in srcData. The stride is the byte count of a scanline (one row of pixels in memory). The stride can be computed from the following formula: pixel width * bytes per pixel + memory padding.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Util.DX.RectL.html">RectL</a></td>
      <td><span class="parametername">destinationArea</span></td>
      <td><p>In the current bitmap, the upper-left corner of the area to which the region specified by srcRect is copied.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">T</span></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory__1___0___System_Int32_C1_Util_DX_RectL__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method does not update the size of the current bitmap. If the contents of the source bitmap do not fit in the current bitmap, this method fails. Also, note that this method does not perform format conversion; the two bitmap formats should match.  Passing this method invalid input, such as an invalid destination rectangle, can produce unpredictable results, such as a distorted image or device failure. Calling this method may cause the current batch to flush if the bitmap is active in the batch. If the batch that was flushed does not complete successfully, this method fails. However, this method does not clear the error state of the render target on which the batch was flushed. The failing <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a> and tag state will be returned at the next call to {{EndDraw}} or {{Flush}}.</p>
</div>


<a id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory*"></a>
<h4 id="C1_Util_DX_Direct2D_Bitmap_CopyFromMemory_System_Nullable_C1_Util_DX_RectL__System_IntPtr_System_Int32_" data-uid="C1.Util.DX.Direct2D.Bitmap.CopyFromMemory(System.Nullable{C1.Util.DX.RectL},System.IntPtr,System.Int32)">CopyFromMemory(RectL?, IntPtr, int)</h4>
<div class="markdown level1 summary"><p>HRESULT ID2D1Bitmap::CopyFromMemory([In, Optional] const D2D_RECT_U* dstRect,[In] const void* srcData,[In] unsigned int pitch)</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void CopyFromMemory(RectL? dstRect, IntPtr srcData, int pitch)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub CopyFromMemory(dstRect As RectL?, srcData As IntPtr, pitch As Integer)</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.RectL.html">RectL</a>?</td>
      <td><span class="parametername">dstRect</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">srcData</span></td>
      <td></td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">pitch</span></td>
      <td></td>
    </tr>
  </tbody>
</table>
</div>
