[英]How do I parse a polyline metafile record out of a byte array?
I need a little help in defining the following Windows GDI type in C#. 在C#中定义以下Windows GDI类型时,我需要一些帮助。 I have the data in the form of a byte[]
in C#, and I need to somehow marshal or cast it as the following in C#. 我在C#中具有byte[]
形式的数据,我需要以某种方式将其编组或转换为C#中的以下内容。 I suppose I need to define the proper struct? 我想我需要定义适当的结构? This is the type: 这是类型:
META_POLYLINE
#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
A polyline is a list of points. 折线是点的列表。 Unlike a polygon, a polyline is always unfilled, and can be open. 与多边形不同,折线始终是未填充的,并且可以打开。
您是否查看过PInvoke.net上的Polyline条目 ?
好的,一条折线的元文件记录...您可能想尝试将Buffer.BlockCopy
从字节数组转换为UInt16
数组。
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);
}
}
(Untested) (未经测试)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.