我需要定义在C#以下的Windows GDI型一点帮助。我有在C#中byte[]形式的数据,我需要以某种方式编组或将它转换为C#以下。我想我需要定义适当的结构?这是类型:

NAME

META_POLYLINE

NEAREST 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);
   }
}

(未测试的)

其他提示

你有没有看了折线进入上PInvoke.net 了吗?

好吧,是折线图元文件记录......你可能想尝试做一个的从字节数组的数组Buffer.BlockCopy UInt16

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top