Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I parse a CREATEPENINDIRECT metafile record out of a byte array?
    text
    copied!<p>I need a little help in defining the following Windows GDI type in C#. I have the data in the form of a <code>byte[]</code> in C#, and I need to somehow marshal or cast it as the following in C#. Please see <a href="https://stackoverflow.com/questions/1773953">my other question</a>, as I got the answer to the Polyline. This is the type:</p> <h3>NAME</h3> <pre><code>META_CREATEPENINDIRECT </code></pre> <h3>NEAREST API CALL</h3> <pre><code>#include &lt;windows.h&gt; HPEN32 CreatePenIndirect(const LOGPEN32 *pen); typedef struct tagLOGPEN { UINT lopnStyle; POINT lopnWidth; COLORREF lopnColor; } LOGPEN; </code></pre> <h3>DESCRIPTION</h3> <pre> U16 Value 0 lopnStyle 1 lopnWidth 2, 3 lopnColor </pre> <blockquote> <p>lopnColor is the color of the pen, lopnWidth is the width of the pen, if the pen's width is &gt; 1 but the lopnStyle is not solid, then lopnStyle is ignored and set to solid anyway.</p> <p>lopnStyle can be one of <code>PS_SOLID</code>, <code>PS_DASH</code>, <code>PS_DOT</code>, <code>PS_DASHDOT</code>, <code>PS_DASHDOTDOT</code>, <code>PS_NULL</code>, <code>PS_INSIDEFRAME</code>, <code>PS_USERSTYLE</code>, <code>PS_ALTERNATE</code>. Check out the source for that they actually mean.</p> <p>Theres also a set of flags and masks that can be found in lopnStyle as well that set the end and join styles of lines drawn with a pen, they are <code>PS_STYLE_MASK</code>, <code>PS_ENDCAP_ROUND</code>, <code>PS_ENDCAP_SQUARE</code>, <code>PS_ENDCAP_FLAT</code>, <code>PS_ENDCAP_MASK</code>, <code>PS_JOIN_ROUND</code>, <code>PS_JOIN_BEVEL</code>, <code>PS_JOIN_MITER</code>, <code>PS_JOIN_MASK</code>, <code>PS_COSMETIC</code>, <code>PS_GEOMETRIC</code>, <code>PS_TYPE_MASK</code>, again check out the source to figure these out.</p> </blockquote> <hr> <p>Update: This is as close as I can get so far:</p> <pre><code>fixed (byte* b = dataArray) { byte* ptr = (byte*)b; // Get style l_nStyle = (ushort)*(ptr); ++ptr; // Get width l_nWidth = (ushort)*(++ptr); ++ptr; // skip one ushort ++ptr; ++ptr; // Get RGB colors l_nColorR = (ushort)*(++ptr); l_nColorG = (ushort)*(++ptr); l_nColorB = (ushort)*(++ptr); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload