在 C# 中定义以下 Windows GDI 类型时,我需要一点帮助。我byte[]
在 C# 中有 a 形式的数据,我需要以某种方式在 C# 中将其编组或强制转换为以下形式。
这是类型:
http://java.freehep.org/vectorgraphics/apidocs/org/freehep/graphicsio/emf/gdi/PolyPolygon16.html
http://msdn.microsoft.com/en-us/library/cc230665%28PROT.10%29.aspx
编辑:我已经能够做到这一点,接近但不完全:
UInt32 rectLeft = BitConverter.ToUInt32(dataArray, 0);
UInt32 rectTop = BitConverter.ToUInt32(dataArray, 4);
UInt32 rectRight = BitConverter.ToUInt32(dataArray, 8);
UInt32 rectBottom = BitConverter.ToUInt32(dataArray, 12);
UInt32 rectNumberOfPolygons = BitConverter.ToUInt32(dataArray, 16);
// Number of points in each polygon
int l_nIndex = 20;
UInt32[] lengths = new UInt32[rectNumberOfPolygons];
for (int i = 0; i < lengths.Length; i++)
{
lengths[i] = BitConverter.ToUInt32(dataArray, l_nIndex);
l_nIndex += 4;
}
// Extract points
foreach (int l_nPolygonLength in lengths)
{
List<Point> l_lstPoints = new List<Point>();
for (int i = 0; i < l_nIndex + l_nPolygonLength; i++)
{
UInt16 pointX = BitConverter.ToUInt16(dataArray, l_nIndex);
UInt16 pointY = BitConverter.ToUInt16(dataArray, l_nIndex + 2);
l_lstPoints.Add(new Point((int)pointX, (int)pointY));
l_nIndex += 4;
}
}