# C1.Win.Document.GraphicsHolder

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="C1_Win_Document_GraphicsHolder" data-uid="C1.Win.Document.GraphicsHolder" class="text-break">GraphicsHolder Class
</h1>
  <div class="markdown level0 summary"><p>Holds a Graphics object together with (printer) device or bitmap that was used
to create it, if any. The point is to dispose the device or bitmap together
with the graphics when it is no longer needed (i.e. to avoid resource leaks).</p>
</div>
  <div class="markdown level0 conceptual"></div>
  <div class="inheritance">
    <h5>Inheritance</h5>
    <div class="level0"><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
    <div class="level1"><span class="xref">GraphicsHolder</span></div>
  </div>
  <div class="implements">
    <h5>Implements</h5>
    <div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.idisposable">IDisposable</a></div>
  </div>
  <h6><strong>Namespace</strong>: <a class="xref" href="C1.Win.Document.html">C1.Win.Document</a></h6>
  <h6><strong>Assembly</strong>: C1.Win.Document.10.dll</h6>
  <h5 id="C1_Win_Document_GraphicsHolder_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public class GraphicsHolder : Object, IDisposable</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public Class GraphicsHolder
    Inherits Object
    Implements IDisposable</code></pre>
  </div>
  <h3 id="fields">Fields
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_Win_Document_GraphicsHolder_Empty" data-uid="C1.Win.Document.GraphicsHolder.Empty">
          <a class="xref" href="C1.Win.Document.GraphicsHolder.Empty.html">Empty</a>
        </td>
        <td class="markdown level1 summary"><p>An empty graphics holder instance.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="properties">Properties
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_Win_Document_GraphicsHolder_DpiX" data-uid="C1.Win.Document.GraphicsHolder.DpiX">
          <a class="xref" href="C1.Win.Document.GraphicsHolder.DpiX.html#C1_Win_Document_GraphicsHolder_DpiX">DpiX</a>
        </td>
        <td class="markdown level1 summary"><p>Gets the horizontal resolution of graphics held by the current instance.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Win_Document_GraphicsHolder_DpiY" data-uid="C1.Win.Document.GraphicsHolder.DpiY">
          <a class="xref" href="C1.Win.Document.GraphicsHolder.DpiY.html#C1_Win_Document_GraphicsHolder_DpiY">DpiY</a>
        </td>
        <td class="markdown level1 summary"><p>Gets the vertical resolution of graphics held by the current instance.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Win_Document_GraphicsHolder_Graphics" data-uid="C1.Win.Document.GraphicsHolder.Graphics">
          <a class="xref" href="C1.Win.Document.GraphicsHolder.Graphics.html#C1_Win_Document_GraphicsHolder_Graphics">Graphics</a>
        </td>
        <td class="markdown level1 summary"><p>Gets the graphics object held by the current instance.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="methods">Methods
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_Win_Document_GraphicsHolder_Dispose" data-uid="C1.Win.Document.GraphicsHolder.Dispose">
          <a class="xref" href="C1.Win.Document.GraphicsHolder.Dispose.html#C1_Win_Document_GraphicsHolder_Dispose">Dispose()</a>
        </td>
        <td class="markdown level1 summary"><p>Disposes the current graphics holder.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Win_Document_GraphicsHolder_Dispose_System_Boolean_" data-uid="C1.Win.Document.GraphicsHolder.Dispose(System.Boolean)">
          <a class="xref" href="C1.Win.Document.GraphicsHolder.Dispose.html#C1_Win_Document_GraphicsHolder_Dispose_System_Boolean_">Dispose(bool)</a>
        </td>
        <td class="markdown level1 summary"><p>Disposes the current graphics holder.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Win_Document_GraphicsHolder_Finalize" data-uid="C1.Win.Document.GraphicsHolder.Finalize">
          <a class="xref" href="C1.Win.Document.GraphicsHolder.Finalize.html#C1_Win_Document_GraphicsHolder_Finalize">Finalize()</a>
        </td>
        <td class="markdown level1 summary"></td>
      </tr>
      <tr>
        <td id="C1_Win_Document_GraphicsHolder_FromBitmap" data-uid="C1.Win.Document.GraphicsHolder.FromBitmap">
          <a class="xref" href="C1.Win.Document.GraphicsHolder.FromBitmap.html#C1_Win_Document_GraphicsHolder_FromBitmap">FromBitmap()</a>
        </td>
        <td class="markdown level1 summary"><p>Creates a graphics holder from a bitmap. The graphics and the bitmap are released when the holder is disposed.
This should never fail.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Win_Document_GraphicsHolder_FromDC_System_IntPtr_" data-uid="C1.Win.Document.GraphicsHolder.FromDC(System.IntPtr)">
          <a class="xref" href="C1.Win.Document.GraphicsHolder.FromDC.html#C1_Win_Document_GraphicsHolder_FromDC_System_IntPtr_">FromDC(IntPtr)</a>
        </td>
        <td class="markdown level1 summary"><p>Creates a graphics holder from a device context.
When the holder is disposed, both graphics and the device context are released (DeleteDC is called on the device context).</p>
</td>
      </tr>
      <tr>
        <td id="C1_Win_Document_GraphicsHolder_FromDevice_C1_Document_MeasurementDevice_System_String_C1_Document_MeasurementDevice__System_String__" data-uid="C1.Win.Document.GraphicsHolder.FromDevice(C1.Document.MeasurementDevice,System.String,C1.Document.MeasurementDevice@,System.String@)">
          <a class="xref" href="C1.Win.Document.GraphicsHolder.FromDevice.html#C1_Win_Document_GraphicsHolder_FromDevice_C1_Document_MeasurementDevice_System_String_C1_Document_MeasurementDevice__System_String__">FromDevice(MeasurementDevice, string, out MeasurementDevice, out string)</a>
        </td>
        <td class="markdown level1 summary"><p>Creates a graphics holder from a printer or screen device contexts, depending on passing parameters.
When the holder is disposed, both graphics and the device context are released (DeleteDC is called on the device context).
If <code class="paramref">printerName</code> is null or specifies invalid printer name
then printer will be autoselected from list of available printers,
if no printers are installed then <a class="xref" href="C1.Win.Document.GraphicsHolder.FromScreen.html#C1_Win_Document_GraphicsHolder_FromScreen">FromScreen()</a> method will be called.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Win_Document_GraphicsHolder_FromGraphics_System_Drawing_Graphics_" data-uid="C1.Win.Document.GraphicsHolder.FromGraphics(System.Drawing.Graphics)">
          <a class="xref" href="C1.Win.Document.GraphicsHolder.FromGraphics.html#C1_Win_Document_GraphicsHolder_FromGraphics_System_Drawing_Graphics_">FromGraphics(Graphics)</a>
        </td>
        <td class="markdown level1 summary"><p>Creates a graphics holder from a graphics instance.
When the holder is disposed, the graphics is left alone (i.e. NOT disposed).</p>
</td>
      </tr>
      <tr>
        <td id="C1_Win_Document_GraphicsHolder_FromScreen" data-uid="C1.Win.Document.GraphicsHolder.FromScreen">
          <a class="xref" href="C1.Win.Document.GraphicsHolder.FromScreen.html#C1_Win_Document_GraphicsHolder_FromScreen">FromScreen()</a>
        </td>
        <td class="markdown level1 summary"><p>Creates a graphics holder from screen. If that fails (e.g. on Azure), the graphics is created from a bitmap.
When the holder is disposed, both graphics and the bitmap are released.</p>
</td>
      </tr>
    </tbody>
  </table>

</div>
