バイト配列からポリライン メタファイル レコードを解析するにはどうすればよいですか?

StackOverflow https://stackoverflow.com/questions/1773953

  •  21-09-2019
  •  | 
  •  

質問

C# で次の Windows GDI 型を定義するには、少し助けが必要です。の形式でデータがあります byte[] C# では、C# で次のようにマーシャリングまたはキャストする必要があります。適切な構造体を定義する必要があると思いますか?これは次のタイプです。

名前

META_POLYLINE

最も近い API 呼び出し

#include <windows.h>
BOOL32 Polyline
(
    HDC32 hdc,
    const POINT32 *pt,
    INT32 count
);

説明

    U16 array no                Value
    --------------------------- --------------
    0                           no of points
    1 each odd until the end    x of the point
    2 each even until the end   y of the point

ポリラインは点のリストです。ポリゴンとは異なり、ポリラインは常に塗りつぶされておらず、開いている場合もあります。

役に立ちましたか?

解決

byte[] buffer;
fixed (byte* b = buffer)
{
   ushort* ptr = (ushort*)b;
   int count = (int)*ptr;
   var points = new Point[count];
   for (int i = 0; i < count; i++)
   {
       int x = (int)*(++ptr);
       int y = (int)*(++ptr);
       points[i] = new Point(x, y);
   }
}

(未テスト)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top