# C1.Util.DX.WIC.Bitmap.Lock

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Util_DX_WIC_Bitmap_Lock_" data-uid="C1.Util.DX.WIC.Bitmap.Lock*">Lock Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Util_DX_WIC_Bitmap_Lock_" data-uid="C1.Util.DX.WIC.Bitmap.Lock*"></a>
<h4 id="C1_Util_DX_WIC_Bitmap_Lock_C1_Util_DX_WIC_BitmapLockFlags_" data-uid="C1.Util.DX.WIC.Bitmap.Lock(C1.Util.DX.WIC.BitmapLockFlags)">Lock(BitmapLockFlags)</h4>
<div class="markdown level1 summary"><p>Provides access to a rectangular area of the bitmap.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public BitmapLock Lock(BitmapLockFlags flags)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function Lock(flags As BitmapLockFlags) As BitmapLock</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.BitmapLockFlags.html">BitmapLockFlags</a></td>
      <td><span class="parametername">flags</span></td>
      <td><dd>
    <p>The access mode you wish to obtain for the lock. This is a bitwise combination of <strong><a class="xref" href="C1.Util.DX.WIC.BitmapLockFlags.html">BitmapLockFlags</a></strong> for read, write, or read and write access.</p>
    <table>
        <tr>
            <th>Value</th>
            <th>Meaning</th>
        </tr>
        <tr>
            <td>
                <dl>
                    <dt>
                        <strong>
                            <a class="xref" href="C1.Util.DX.WIC.BitmapLockFlags.html#C1_Util_DX_WIC_BitmapLockFlags_Read">Read</a>
                        </strong>
                    </dt>
                </dl>
            </td>
            <td>
                <p>The read access lock.</p>
            </td>
        </tr>
        <tr>
            <td>
                <dl>
                    <dt>
                        <strong>
                            <a class="xref" href="C1.Util.DX.WIC.BitmapLockFlags.html#C1_Util_DX_WIC_BitmapLockFlags_Write">Write</a>
                        </strong>
                    </dt>
                </dl>
            </td>
            <td>
                <p>The write access lock.</p>
            </td>
        </tr>
    </table>
    <p>?</p>
</dd>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Util.DX.WIC.BitmapLock.html">BitmapLock</a></td>
      <td><dd>
    <p>A reference that receives the locked memory location.</p>
</dd>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_WIC_Bitmap_Lock_C1_Util_DX_WIC_BitmapLockFlags__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Locks are exclusive for writing but can be shared for reading. You cannot call <strong>CopyPixels</strong> while the <strong><a class="xref" href="C1.Util.DX.WIC.Bitmap.html">Bitmap</a></strong> is locked for writing. Doing so will return an error, since locks are exclusive.</p>
</div>


<a id="C1_Util_DX_WIC_Bitmap_Lock_" data-uid="C1.Util.DX.WIC.Bitmap.Lock*"></a>
<h4 id="C1_Util_DX_WIC_Bitmap_Lock_C1_Util_DX_RectL_C1_Util_DX_WIC_BitmapLockFlags_" data-uid="C1.Util.DX.WIC.Bitmap.Lock(C1.Util.DX.RectL,C1.Util.DX.WIC.BitmapLockFlags)">Lock(RectL, BitmapLockFlags)</h4>
<div class="markdown level1 summary"><p>Provides access to a rectangular area of the bitmap.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public BitmapLock Lock(RectL rcLockRef, BitmapLockFlags flags)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function Lock(rcLockRef As RectL, flags As BitmapLockFlags) As BitmapLock</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">rcLockRef</span></td>
      <td><dd>
    <p>The rectangle to be accessed.</p>
</dd>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Util.DX.WIC.BitmapLockFlags.html">BitmapLockFlags</a></td>
      <td><span class="parametername">flags</span></td>
      <td><dd>
    <p>The access mode you wish to obtain for the lock. This is a bitwise combination of <strong><a class="xref" href="C1.Util.DX.WIC.BitmapLockFlags.html">BitmapLockFlags</a></strong> for read, write, or read and write access.</p>
    <table>
        <tr>
            <th>Value</th>
            <th>Meaning</th>
        </tr>
        <tr>
            <td>
                <dl>
                    <dt>
                        <strong>
                            <a class="xref" href="C1.Util.DX.WIC.BitmapLockFlags.html#C1_Util_DX_WIC_BitmapLockFlags_Read">Read</a>
                        </strong>
                    </dt>
                </dl>
            </td>
            <td>
                <p>The read access lock.</p>
            </td>
        </tr>
        <tr>
            <td>
                <dl>
                    <dt>
                        <strong>
                            <a class="xref" href="C1.Util.DX.WIC.BitmapLockFlags.html#C1_Util_DX_WIC_BitmapLockFlags_Write">Write</a>
                        </strong>
                    </dt>
                </dl>
            </td>
            <td>
                <p>The write access lock.</p>
            </td>
        </tr>
    </table>
    <p>?</p>
</dd>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Util.DX.WIC.BitmapLock.html">BitmapLock</a></td>
      <td><dd>
    <p>A reference that receives the locked memory location.</p>
</dd>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_WIC_Bitmap_Lock_C1_Util_DX_RectL_C1_Util_DX_WIC_BitmapLockFlags__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Locks are exclusive for writing but can be shared for reading. You cannot call <strong>CopyPixels</strong> while the <strong><a class="xref" href="C1.Util.DX.WIC.Bitmap.html">Bitmap</a></strong> is locked for writing. Doing so will return an error, since locks are exclusive.</p>
</div>


<a id="C1_Util_DX_WIC_Bitmap_Lock_" data-uid="C1.Util.DX.WIC.Bitmap.Lock*"></a>
<h4 id="C1_Util_DX_WIC_Bitmap_Lock_System_IntPtr_C1_Util_DX_WIC_BitmapLockFlags_" data-uid="C1.Util.DX.WIC.Bitmap.Lock(System.IntPtr,C1.Util.DX.WIC.BitmapLockFlags)">Lock(IntPtr, BitmapLockFlags)</h4>
<div class="markdown level1 summary"><p>HRESULT IWICBitmap::Lock([In] const void* prcLock,[In] WICBitmapLockFlags flags,[Out] IWICBitmapLock** ppILock)</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public BitmapLock Lock(IntPtr rcLockRef, BitmapLockFlags flags)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function Lock(rcLockRef As IntPtr, flags As BitmapLockFlags) As BitmapLock</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">rcLockRef</span></td>
      <td></td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Util.DX.WIC.BitmapLockFlags.html">BitmapLockFlags</a></td>
      <td><span class="parametername">flags</span></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Util.DX.WIC.BitmapLock.html">BitmapLock</a></td>
      <td></td>
    </tr>
  </tbody>
</table>
</div>
